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 0f07e0a..fb0f04e 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 702010a..094f210 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 292cfed..642bf15 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