aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2023-02-01 21:01:32 +0100
committerHarald Anlauf <anlauf@gmx.de>2023-02-11 14:56:16 +0100
commit684a5a8734c4269786089f5d4ba0fbf79f190f3a (patch)
treefdd99ac03fd3dd22e940b07c97283e175952a21b /gcc/fortran
parent2965a4f925461d7814972845fe480e03856fe3fe (diff)
downloadgcc-684a5a8734c4269786089f5d4ba0fbf79f190f3a.zip
gcc-684a5a8734c4269786089f5d4ba0fbf79f190f3a.tar.gz
gcc-684a5a8734c4269786089f5d4ba0fbf79f190f3a.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.c (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. (cherry picked from commit 88a2a09dd4529107e7ef7a6e7ce43acf96457173)
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/expr.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index b65fc76..5f22270 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -1549,7 +1549,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;