From 13a7688fb902adb314679a2ffe64d80186632224 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Tue, 27 Mar 2018 17:28:35 +0000 Subject: [PATCH] re PR fortran/85083 (ICE in gfc_convert_to_structure_constructor, at fortran/primary.c:2915) 2018-03-27 Thomas Koenig Harald Anlauf PR fortran/85083 * primary.c (gfc_convert_to_structure_constructor): Check conformance of argument types in structure constructor. 2018-03-27 Thomas Koenig Harald Anlauf * gfortran.dg/structure_constructor_15.f90: New test. Co-Authored-By: Harald Anlauf From-SVN: r258899 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/primary.c | 1 + gcc/testsuite/ChangeLog | 5 +++++ .../gfortran.dg/structure_constructor_15.f90 | 12 ++++++++++++ 4 files changed, 25 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/structure_constructor_15.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0f07e0a30d9..fb0f04e47f0 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2018-03-27 Thomas Koenig + Harald Anlauf + + PR fortran/85083 + * primary.c (gfc_convert_to_structure_constructor): Check + conformance of argument types in structure constructor. + 2018-03-26 Thomas Koenig PR fortran/66709 diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index 702010a026c..094f2101bbc 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -2898,6 +2898,7 @@ gfc_convert_to_structure_constructor (gfc_expr *e, gfc_symbol *sym, gfc_expr **c if (this_comp->ts.type == BT_CHARACTER && !this_comp->attr.allocatable && this_comp->ts.u.cl && this_comp->ts.u.cl->length && this_comp->ts.u.cl->length->expr_type == EXPR_CONSTANT + && actual->expr->ts.type == BT_CHARACTER && actual->expr->expr_type == EXPR_CONSTANT) { ptrdiff_t c, e; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 292cfedac1e..642bf15852b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-27 Thomas Koenig + Harald Anlauf + + * gfortran.dg/structure_constructor_15.f90: New test. + 2018-03-27 Volker Reichelt * g++.dg/cpp0x/defaulted2.C: Use dg-message instead of dg-error diff --git a/gcc/testsuite/gfortran.dg/structure_constructor_15.f90 b/gcc/testsuite/gfortran.dg/structure_constructor_15.f90 new file mode 100644 index 00000000000..583e3abafe1 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/structure_constructor_15.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! PR 85083 +! +! Testcase from PR by G. Steinmetz +! +program p + type t + character(3) :: c + end type t + type(t), allocatable :: z + allocate (z, source=t(.true.,'abc')) ! { dg-error "Too many components" } +end -- 2.30.2