[fortran] PR85083 - [8 Regression] ICE in gfc_convert_to_structure_constructor, at fortran/primary.c:2915

Message ID 5AB96665.1080407@gmx.de
State New
Headers show
Series
  • [fortran] PR85083 - [8 Regression] ICE in gfc_convert_to_structure_constructor, at fortran/primary.c:2915
Related show

Commit Message

Harald Anlauf March 26, 2018, 9:30 p.m.
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  <anlauf@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  <anlauf@gmx.de>

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

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  <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

Comments

Thomas Koenig March 27, 2018, 5:32 p.m. | #1
Hello Harald,

> 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.



Reviewed and dommitted as r258899.  I have changed the test case name to
structure_constructor_15.f90 because this sort of name allows
running tests on a meaningful subset of interest, for example with
make check-fortran RUNTESTFLAGS="dg.exp=gfortran.dg/*constructor*".

Thanks a lot for the patch!

Regards

	Thomas

Patch

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;