Re: [PATCH] PR fortran/78571 -- Avoid ICE in invalid CHARACTER initialization

2018-06-08 Thread Steve Kargl
On Fri, Jun 08, 2018 at 09:01:11PM +0200, Thomas König wrote:
> > Regression tested on x86_64-*-freebsd.  OK to commit?
> 
> OK, and thanks!
> 

Thanks.  Committed to trunk.

-- 
Steve


Re: [PATCH] PR fortran/78571 -- Avoid ICE in invalid CHARACTER initialization

2018-06-08 Thread Thomas König

Hi Steve,


Regression tested on x86_64-*-freebsd.  OK to commit?


OK, and thanks!

Thomas


[PATCH] PR fortran/78571 -- Avoid ICE in invalid CHARACTER initialization

2018-06-07 Thread Steve Kargl
Regression tested on x86_64-*-freebsd.  OK to commit?

2018-06-07  Steven G. Kargl  

PR fortran/78571
* data.c (create_character_initializer): Return early if type is
incompatible with CHARACTER.

2018-06-07  Steven G. Kargl  

PR fortran/78571
* gfortran.dg/pr78571.f90: New test.

-- 
Steve
Index: gcc/fortran/data.c
===
--- gcc/fortran/data.c	(revision 261285)
+++ gcc/fortran/data.c	(working copy)
@@ -107,7 +107,10 @@ create_character_initializer (gfc_expr *init, gfc_type
   HOST_WIDE_INT len, start, end, tlen;
   gfc_char_t *dest;
   bool alloced_init = false;
-	
+
+  if (init && init->ts.type != BT_CHARACTER)
+return NULL;
+
   gfc_extract_hwi (ts->u.cl->length, );
 
   if (init == NULL)
Index: gcc/testsuite/gfortran.dg/pr78571.f90
===
--- gcc/testsuite/gfortran.dg/pr78571.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr78571.f90	(working copy)
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! PR fortran/78571
+program p
+   type t
+  character :: c
+   end type
+   character :: x = t('a') ! { dg-error "convert TYPE" }
+   data x /'b'/
+end