aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/fortran/frontend-passes.c4
-rw-r--r--gcc/testsuite/gfortran.dg/pr103607.f9012
2 files changed, 16 insertions, 0 deletions
diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c
index 4764c83..57b24a1 100644
--- a/gcc/fortran/frontend-passes.c
+++ b/gcc/fortran/frontend-passes.c
@@ -2914,6 +2914,7 @@ do_subscript (gfc_expr **e)
{
if (ar->as->lower[i]
&& ar->as->lower[i]->expr_type == EXPR_CONSTANT
+ && ar->as->lower[i]->ts.type == BT_INTEGER
&& mpz_cmp (val, ar->as->lower[i]->value.integer) < 0)
gfc_warning (warn, "Array reference at %L out of bounds "
"(%ld < %ld) in loop beginning at %L",
@@ -2923,6 +2924,7 @@ do_subscript (gfc_expr **e)
if (ar->as->upper[i]
&& ar->as->upper[i]->expr_type == EXPR_CONSTANT
+ && ar->as->upper[i]->ts.type == BT_INTEGER
&& mpz_cmp (val, ar->as->upper[i]->value.integer) > 0)
gfc_warning (warn, "Array reference at %L out of bounds "
"(%ld > %ld) in loop beginning at %L",
@@ -2938,6 +2940,7 @@ do_subscript (gfc_expr **e)
{
if (ar->as->lower[i]
&& ar->as->lower[i]->expr_type == EXPR_CONSTANT
+ && ar->as->lower[i]->ts.type == BT_INTEGER
&& mpz_cmp (val, ar->as->lower[i]->value.integer) < 0)
gfc_warning (warn, "Array reference at %L out of bounds "
"(%ld < %ld) in loop beginning at %L",
@@ -2947,6 +2950,7 @@ do_subscript (gfc_expr **e)
if (ar->as->upper[i]
&& ar->as->upper[i]->expr_type == EXPR_CONSTANT
+ && ar->as->upper[i]->ts.type == BT_INTEGER
&& mpz_cmp (val, ar->as->upper[i]->value.integer) > 0)
gfc_warning (warn, "Array reference at %L out of bounds "
"(%ld > %ld) in loop beginning at %L",
diff --git a/gcc/testsuite/gfortran.dg/pr103607.f90 b/gcc/testsuite/gfortran.dg/pr103607.f90
new file mode 100644
index 0000000..a6a2c4f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr103607.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! PR fortran/103607 - ICE in do_subscript, at fortran/frontend-passes.c:2927
+! Contributed by G.Steinmetz
+
+program p
+ integer :: i, x(abs(2.)) ! { dg-error "must be of INTEGER type" }
+ do i = 1, 2
+ x(i) = 0
+ end do
+end
+
+! { dg-prune-output "must have constant shape" }