re PR fortran/69867 (ICE on initializing character in type with array of incompatible...
authorSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 30 Jul 2016 20:05:10 +0000 (20:05 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 30 Jul 2016 20:05:10 +0000 (20:05 +0000)
2016-07-30  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/69867
* decl.c (build_struct): Ensure that pointers point to something.

2016-07-30  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/69867
* gfortran.dg/pr69867.f90: New test.

From-SVN: r238907

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

index 5e8e7d1b8207c839816ca093b37c111cf8553fd8..13f1a9089dbe41c1c069d4b3c3e4e53eef07fd0d 100644 (file)
@@ -1,3 +1,8 @@
+2016-07-30  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/69867
+       * decl.c (build_struct): Ensure that pointers point to something.
+
 2016-07-30  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/69962
index ae68c09f586e31e5b9084a22a883a6fbdc634077..818e7d4ca988cd6d6390e263fea49d3307ff6f02 100644 (file)
@@ -1926,8 +1926,10 @@ build_struct (const char *name, gfc_charlen *cl, gfc_expr **init,
 
       if (c->initializer->expr_type == EXPR_CONSTANT)
        gfc_set_constant_character_len (len, c->initializer, -1);
-      else if (mpz_cmp (c->ts.u.cl->length->value.integer,
-                       c->initializer->ts.u.cl->length->value.integer))
+      else if (c->initializer
+               && c->initializer->ts.u.cl
+               && mpz_cmp (c->ts.u.cl->length->value.integer,
+                           c->initializer->ts.u.cl->length->value.integer))
        {
          gfc_constructor *ctor;
          ctor = gfc_constructor_first (c->initializer->value.constructor);
index 73e2258fa29988e93d78c9c108f8c28024293ef9..8625717c5bfd0c32845035ab2a859a7ddae578c2 100644 (file)
@@ -1,3 +1,8 @@
+2016-07-30  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/69867
+       * gfortran.dg/pr69867.f90: New test.
+
 2016-07-30  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/69962
diff --git a/gcc/testsuite/gfortran.dg/pr69867.f90 b/gcc/testsuite/gfortran.dg/pr69867.f90
new file mode 100644 (file)
index 0000000..132d5e8
--- /dev/null
@@ -0,0 +1,6 @@
+! { dg-do compile }
+program p
+ type t
+  character(1) :: c(1)=[1] ! { dg-error "convert INTEGER.4. to CHARACTER.1." }
+ end type
+end