re PR fortran/78571 (ICE in create_character_initializer, at fortran/data.c:191)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 8 Jun 2018 19:06:20 +0000 (19:06 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 8 Jun 2018 19:06:20 +0000 (19:06 +0000)
2018-06-08  Steven G. Kargl  <kargl@gcc.gnu.org>

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

2018-06-08  Steven G. Kargl  <kargl@gcc.gnu.org>

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

From-SVN: r261343

gcc/fortran/ChangeLog
gcc/fortran/data.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr78571.f90 [new file with mode: 0644]

index 7acc4c6..b48f11c 100644 (file)
@@ -1,3 +1,9 @@
+2018-06-08  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/78571
+       * data.c (create_character_initializer): Return early if type is
+       incompatible with CHARACTER.
+
 2018-06-07  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/86045
index 780a5ad..d837e15 100644 (file)
@@ -107,7 +107,10 @@ create_character_initializer (gfc_expr *init, gfc_typespec *ts,
   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, &len);
 
   if (init == NULL)
index 3b3bc5a..a4d18b3 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-08  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/78571
+       * gfortran.dg/pr78571.f90: New test.
+
 2018-06-08  Peter Bergner  <bergner@vnet.ibm.com>
 
        PR target/85755
diff --git a/gcc/testsuite/gfortran.dg/pr78571.f90 b/gcc/testsuite/gfortran.dg/pr78571.f90
new file mode 100644 (file)
index 0000000..16b07ab
--- /dev/null
@@ -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