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 7acc4c6c2fdd1c1026831fe78329b2b3f7049921..b48f11c2b67e2b7d4ea5936f9a1534439146a3bf 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 780a5ad9564ad69effa338ebeaabbef8f02ee34e..d837e15ee282d31a2fe12d1a7671bc3655c4809a 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 3b3bc5a7f15d22ef6d2835ddedaff787831dcf55..a4d18b34b0757e7c6ba34a7ea79cdf396345b581 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