re PR fortran/85102 (ICE in gfc_conv_intrinsic_dot_product, at fortran/trans-intrinsi...
authorThomas Koenig <tkoenig@gcc.gnu.org>
Mon, 2 Apr 2018 16:47:48 +0000 (16:47 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Mon, 2 Apr 2018 16:47:48 +0000 (16:47 +0000)
2018-04-02  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/85102
* decl.c (variable_decl): If upper or lower bounds simplify
to a constant, use that.

2018-04-02  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/85102
* gfortran.dg/array_simplify_2.f90: New test.

From-SVN: r259014

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

index e2765e1e73ad0d6fb44b2c50d70e8a52e2eddb5e..1d90f4fa317fd67f97e0f06530b713d72f80c2f8 100644 (file)
@@ -1,3 +1,9 @@
+2018-04-02  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/85102
+       * decl.c (variable_decl): If upper or lower bounds simplify
+       to a constant, use that.
+
 2018-03-30  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/84931
index dce9dd2d6df428d5445230432e7ec9607a59e9ff..192910dfe65984d1f3e032425d53b328f233ebea 100644 (file)
@@ -2424,6 +2424,33 @@ variable_decl (int elem)
              goto cleanup;
            }
        }
+      if (as->type == AS_EXPLICIT)
+       {
+         for (int i = 0; i < as->rank; i++)
+           {
+             gfc_expr *e, *n;
+             e = as->lower[i];
+             if (e->expr_type != EXPR_CONSTANT)
+               {
+                 n = gfc_copy_expr (e);
+                 gfc_simplify_expr (n, 1);
+                 if (n->expr_type == EXPR_CONSTANT)
+                   gfc_replace_expr (e, n);
+                 else
+                   gfc_free_expr (n);
+               }
+             e = as->upper[i];
+             if (e->expr_type != EXPR_CONSTANT)
+               {
+                 n = gfc_copy_expr (e);
+                 gfc_simplify_expr (n, 1);
+                 if (n->expr_type == EXPR_CONSTANT)
+                   gfc_replace_expr (e, n);
+                 else
+                   gfc_free_expr (n);
+               }
+           }
+       }
     }
 
   char_len = NULL;
index 7fddf8c271a29cba07e8d87fb2c837242cbedc92..ca5953f2234cc338d9b5e03f624e378ad73671f3 100644 (file)
@@ -1,3 +1,8 @@
+2018-04-02  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/85102
+       * gfortran.dg/array_simplify_2.f90: New test.
+
 2018-04-01  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/85090
diff --git a/gcc/testsuite/gfortran.dg/array_simplify_2.f90 b/gcc/testsuite/gfortran.dg/array_simplify_2.f90
new file mode 100644 (file)
index 0000000..3645404
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do  run }
+! PR 85102 - this used to ICE
+! Original test case by Gerhard Steinmetz
+program p
+   integer, parameter :: a((1+2)) = 1
+   integer, parameter :: b((1+1)+1) = 1
+   integer, parameter :: c = dot_product(a, a)
+   integer, parameter :: d = dot_product(b,b)
+   if (c /= 3) stop 1
+   if (d /= 3) stop 2
+ end program p