]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/71066 (ICE in set_loop_bounds, at fortran/trans-array.c:4680)
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sat, 23 Feb 2019 11:49:47 +0000 (11:49 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sat, 23 Feb 2019 11:49:47 +0000 (11:49 +0000)
2019-02-23  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/71066
Backport from trunk
* trans-decl.c (generate_coarray_sym_init):  For an array
constructor in a DATA statement of a coarray variable, set the
rank to 1 to avoid confusion later on.  If the constructor
contains only one value, use that for initiailizig.

2019-02-23  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/71066
Backport from trunk
* gfortran.dg/coarray_data_1.f90: New test.

From-SVN: r269155

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

index 01373f0e9e9892ab041015538394acde511b4f78..729d965350ebea249fb44f3d0b2fff6f2e06b18d 100644 (file)
@@ -1,3 +1,12 @@
+2019-02-23  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/71066
+       Backport from trunk
+       * trans-decl.c (generate_coarray_sym_init):  For an array
+       constructor in a DATA statement of a coarray variable, set the
+       rank to 1 to avoid confusion later on.  If the constructor
+       contains only one value, use that for initiailizig.
+
 2019-02-10  Harald Anlauf  <anlauf@gmx.de>
 
        Backport from trunk
index f0a2e03ecf25bf4712ca8a802b20c9f7028e892d..c43f8e46dc5146c22413e4fe067a41982c4ddacf 100644 (file)
@@ -5222,6 +5222,33 @@ generate_coarray_sym_init (gfc_symbol *sym)
   /* Handle "static" initializer.  */
   if (sym->value)
     {
+      if (sym->value->expr_type == EXPR_ARRAY)
+       {
+         gfc_constructor *c, *cnext;
+
+         /* Test if the array has more than one element.  */
+         c = gfc_constructor_first (sym->value->value.constructor);
+         gcc_assert (c);  /* Empty constructor should not happen here.  */
+         cnext = gfc_constructor_next (c);
+
+         if (cnext)
+           {
+             /* An EXPR_ARRAY with a rank > 1 here has to come from a
+                DATA statement.  Set its rank here as not to confuse
+                the following steps.   */
+             sym->value->rank = 1;
+           }
+         else
+           {
+             /* There is only a single value in the constructor, use
+                it directly for the assignment.  */
+             gfc_expr *new_expr;
+             new_expr = gfc_copy_expr (c->expr);
+             gfc_free_expr (sym->value);
+             sym->value = new_expr;
+           }
+       }
+
       sym->attr.pointer = 1;
       tmp = gfc_trans_assignment (gfc_lval_expr_from_sym (sym), sym->value,
                                  true, false);
index 2a9f45f45bcc4c1b8218e81d359af86dddfdf3da..9fe2ddb11f3b61f0209ffca8a4a54a0e8c40e3cb 100644 (file)
@@ -1,3 +1,9 @@
+2019-02-23  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/71066
+       Backport from trunk
+       * gfortran.dg/coarray_data_1.f90: New test.
+
 2019-02-15  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
diff --git a/gcc/testsuite/gfortran.dg/coarray_data_1.f90 b/gcc/testsuite/gfortran.dg/coarray_data_1.f90
new file mode 100644 (file)
index 0000000..94ab4c2
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do  run }
+! { dg-options "-fcoarray=lib -lcaf_single " }
+! PR 71066 - this used to ICE
+program p
+   real :: a(2,2)[*]
+   integer :: b(2,2)[*]
+   data a /4*0.0/
+   data b /1234, 2345, 3456, 4567/
+   if (any (a /= 0.0)) stop 1
+   if (any (b /= reshape([1234, 2345, 3456, 4567],[2,2]))) stop 2
+end