aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2018-04-02 16:47:48 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2018-04-02 16:47:48 +0000
commit078c5aff5ed83e9c237f3090e947860314838e00 (patch)
treeb81a2e4f6cf9728908b1970f8a5c4ef93655ee7b /gcc
parentc54a138f843e86571ff8a3ff29dbddf1d4489849 (diff)
downloadgcc-078c5aff5ed83e9c237f3090e947860314838e00.zip
gcc-078c5aff5ed83e9c237f3090e947860314838e00.tar.gz
gcc-078c5aff5ed83e9c237f3090e947860314838e00.tar.bz2
re PR fortran/85102 (ICE in gfc_conv_intrinsic_dot_product, at fortran/trans-intrinsic.c:4464)
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/decl.c27
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/array_simplify_2.f9011
4 files changed, 49 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index e2765e1..1d90f4f 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -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
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index dce9dd2..192910d 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -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;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7fddf8c..ca5953f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..3645404
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/array_simplify_2.f90
@@ -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