re PR fortran/85083 (ICE in gfc_convert_to_structure_constructor, at fortran/primary...
authorThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 27 Mar 2018 17:28:35 +0000 (17:28 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 27 Mar 2018 17:28:35 +0000 (17:28 +0000)
2018-03-27  Thomas Koenig  <tkoenig@gcc.gnu.org>
Harald Anlauf  <anlauf@gmx.de>

PR fortran/85083
* primary.c (gfc_convert_to_structure_constructor): Check
conformance of argument types in structure constructor.

2018-03-27  Thomas Koenig  <tkoenig@gcc.gnu.org>
Harald Anlauf  <anlauf@gmx.de>

* gfortran.dg/structure_constructor_15.f90: New test.

Co-Authored-By: Harald Anlauf <anlauf@gmx.de>
From-SVN: r258899

gcc/fortran/ChangeLog
gcc/fortran/primary.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/structure_constructor_15.f90 [new file with mode: 0644]

index 0f07e0a30d921e146268f5aecf3be53f502ef75f..fb0f04e47f02a5f64258da62e3b4be733274c75e 100644 (file)
@@ -1,3 +1,10 @@
+2018-03-27  Thomas Koenig  <tkoenig@gcc.gnu.org>
+       Harald Anlauf  <anlauf@gmx.de>
+
+       PR fortran/85083
+       * primary.c (gfc_convert_to_structure_constructor): Check
+       conformance of argument types in structure constructor.
+
 2018-03-26  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/66709
index 702010a026c6293169b6c69f5be2c643f60e7d77..094f2101bbc553fb27f375eac8195e4e0a2a974c 100644 (file)
@@ -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;
index 292cfedac1e5fa5272ca9abde124a9160431179d..642bf15852b3dcd1e6d4f497c449d8bfd0c9675d 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-27  Thomas Koenig  <tkoenig@gcc.gnu.org>
+       Harald Anlauf  <anlauf@gmx.de>
+
+       * gfortran.dg/structure_constructor_15.f90: New test.
+
 2018-03-27  Volker Reichelt  <v.reichelt@netcologne.de>
 
        * 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 (file)
index 0000000..583e3ab
--- /dev/null
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! PR 85083
+!
+! Testcase from PR by G. Steinmetz  <gscfq@t-online.de>
+!
+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