public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, fortran] PR85083 - [8 Regression] ICE in gfc_convert_to_structure_constructor, at fortran/primary.c:2915
@ 2018-03-26 21:30 Harald Anlauf
  2018-03-27 17:33 ` Thomas Koenig
  0 siblings, 1 reply; 2+ messages in thread
From: Harald Anlauf @ 2018-03-26 21:30 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 527 bytes --]

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.


[-- Attachment #2: patch-pr85083 --]
[-- Type: text/plain, Size: 518 bytes --]

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;

[-- Attachment #3: patch-pr85083-testcase --]
[-- Type: text/plain, Size: 506 bytes --]

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH, fortran] PR85083 - [8 Regression] ICE in gfc_convert_to_structure_constructor, at fortran/primary.c:2915
  2018-03-26 21:30 [PATCH, fortran] PR85083 - [8 Regression] ICE in gfc_convert_to_structure_constructor, at fortran/primary.c:2915 Harald Anlauf
@ 2018-03-27 17:33 ` Thomas Koenig
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Koenig @ 2018-03-27 17:33 UTC (permalink / raw)
  To: Harald Anlauf, fortran, gcc-patches

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-27 17:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-26 21:30 [PATCH, fortran] PR85083 - [8 Regression] ICE in gfc_convert_to_structure_constructor, at fortran/primary.c:2915 Harald Anlauf
2018-03-27 17:33 ` Thomas Koenig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).