re PR fortran/71203 (ICE in add_init_expr_to_sym, at fortran/decl.c:1512 and :1564)
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sat, 9 Mar 2019 14:10:17 +0000 (14:10 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sat, 9 Mar 2019 14:10:17 +0000 (14:10 +0000)
2019-03-09  Thomas König  <tkoenig@gcc.gnu.org>

PR fortran/71203
* decl.c (add_init_expr_to_sym):  Add shape if init has none.  Add
assert that it has to be an EXPR_ARRAY in this case.

2019-03-09  Thomas König  <tkoenig@gcc.gnu.org>

PR fortran/71203
* gfortran.dg/array_simplify_3.f90: New test case.

From-SVN: r269526

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

index 28403689bb10f89cfbdc1367a2691ecb01e77b56..48ab06b0a185bf04da41096b813afe6059367e3c 100644 (file)
@@ -1,3 +1,9 @@
+2019-03-09  Thomas König  <tkoenig@gcc.gnu.org>
+
+       PR fortran/71203
+       * decl.c (add_init_expr_to_sym):  Add shape if init has none.  Add
+       asserts that it has to be an EXPR_ARRAY in this case.
+
 2019-03-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR other/80058
index 3c8c5ffaaaa151d17e887f7714126bbaa0f81229..31c7fb6325ce43c60f3e68fe258ad729f85ec91e 100644 (file)
@@ -1983,8 +1983,14 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus)
              return false;
            }
 
-         /* Shape should be present, we get an initialization expression.  */
-         gcc_assert (init->shape);
+         /* The shape may be NULL for EXPR_ARRAY, set it.  */
+         if (init->shape == NULL)
+           {
+             gcc_assert (init->expr_type == EXPR_ARRAY);
+             init->shape = gfc_get_shape (1);
+             if (!gfc_array_size (init, &init->shape[0]))
+                 gfc_internal_error ("gfc_array_size failed");
+           }
 
          for (dim = 0; dim < sym->as->rank; ++dim)
            {
index 6b131cbc5fcd99b84d6692bae1ab401227d95b75..d100f1bcdcd58580e52c293817d01bc1040d057a 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-09  Thomas König  <tkoenig@gcc.gnu.org>
+
+       PR fortran/71203
+       * gfortran.dg/array_simplify_3.f90: New test case.
+
 2019-03-09  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/88568
diff --git a/gcc/testsuite/gfortran.dg/array_simplify_3.f90 b/gcc/testsuite/gfortran.dg/array_simplify_3.f90
new file mode 100644 (file)
index 0000000..31183b0
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do  run }
+! PR 71203 - this used to ICE
+program p
+   integer :: i
+   integer, parameter :: x(2) = 0
+   integer, parameter :: y(*) = [(x(i:i), i=1,2)]
+   if (size(y,1) /= 2) stop 1
+   if (any(y /= 0)) stop 2
+end