The attached obvious one-liner adds a missing check for type
compatibility in a structure constructor.

Testcase from report.  Changelogs below.

Regtested on i686-pc-linux-gnu.

Whoever reviews this, please feel free to commit.

Thanks,
Harald

2018-03-26  Harald Anlauf  <anl...@gmx.de>

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


2018-03-26  Harald Anlauf  <anl...@gmx.de>

        PR fortran/85083
        * gfortran.dg/pr85083.f90: New test.

Index: gcc/fortran/primary.c
===================================================================
--- gcc/fortran/primary.c       (revision 258846)
+++ gcc/fortran/primary.c       (working copy)
@@ -2898,6 +2898,7 @@
       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: gcc/testsuite/gfortran.dg/pr85083.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr85083.f90       (revision 0)
+++ gcc/testsuite/gfortran.dg/pr85083.f90       (revision 0)
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! PR 85083
+!
+! Testcase from PR by G. Steinmetz  <gs...@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

Reply via email to