aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2023-02-01 21:01:32 +0100
committerHarald Anlauf <anlauf@gmx.de>2023-02-01 21:01:32 +0100
commit88a2a09dd4529107e7ef7a6e7ce43acf96457173 (patch)
tree51decfe2710b4a2afbc11cc50e1874afc5db3630
parenta2c848c92c3f13c2dd9bd92d22beb44c1ff848b4 (diff)
downloadgcc-88a2a09dd4529107e7ef7a6e7ce43acf96457173.zip
gcc-88a2a09dd4529107e7ef7a6e7ce43acf96457173.tar.gz
gcc-88a2a09dd4529107e7ef7a6e7ce43acf96457173.tar.bz2
Fortran: error recovery on invalid array section [PR108609]
The testcase for PR108527 uncovered a latent issue with invalid array sections that resulted in different paths being taken on different architectures. Detect the invalid array declaration for a clean recovery. gcc/fortran/ChangeLog: PR fortran/108609 * expr.cc (find_array_section): Add check to prevent interpreting an mpz non-integer constant as an integer. gcc/testsuite/ChangeLog: PR fortran/108609 * gfortran.dg/pr108527.f90: Adjust test pattern.
-rw-r--r--gcc/fortran/expr.cc6
-rw-r--r--gcc/testsuite/gfortran.dg/pr108527.f902
2 files changed, 6 insertions, 2 deletions
diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index 3036b1b..c295721 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -1552,7 +1552,11 @@ find_array_section (gfc_expr *expr, gfc_ref *ref)
lower = ref->u.ar.as->lower[d];
upper = ref->u.ar.as->upper[d];
- if (!lower || !upper)
+ if (!lower || !upper
+ || lower->expr_type != EXPR_CONSTANT
+ || upper->expr_type != EXPR_CONSTANT
+ || lower->ts.type != BT_INTEGER
+ || upper->ts.type != BT_INTEGER)
{
t = false;
goto cleanup;
diff --git a/gcc/testsuite/gfortran.dg/pr108527.f90 b/gcc/testsuite/gfortran.dg/pr108527.f90
index c97ba31..8045148 100644
--- a/gcc/testsuite/gfortran.dg/pr108527.f90
+++ b/gcc/testsuite/gfortran.dg/pr108527.f90
@@ -4,7 +4,7 @@
program p
integer, parameter :: a((2.)) = [4,8] ! { dg-error "must be of INTEGER type" }
- integer(a(1:1)) :: b ! { dg-error "out of bounds" }
+ integer(a(1:1)) :: b ! { dg-error "Unclassifiable statement" }
end
! { dg-prune-output "Parameter array" }