aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/simplify.c
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2021-09-30 20:29:31 +0200
committerHarald Anlauf <anlauf@gmx.de>2021-09-30 20:29:31 +0200
commitb19bbfb1482505367dd19ae4ab1ea19e36802b6a (patch)
treecefdb5e5b056c1ebf3bf9ad3df6dee2d9c8dd260 /gcc/fortran/simplify.c
parent8a0861ef29521e90293bd0236d2bb30b71a4970e (diff)
downloadgcc-b19bbfb1482505367dd19ae4ab1ea19e36802b6a.zip
gcc-b19bbfb1482505367dd19ae4ab1ea19e36802b6a.tar.gz
gcc-b19bbfb1482505367dd19ae4ab1ea19e36802b6a.tar.bz2
Fortran: resolve expressions during SIZE simplification
gcc/fortran/ChangeLog: PR fortran/102458 * simplify.c (simplify_size): Resolve expressions used in array specifications so that SIZE can be simplified. gcc/testsuite/ChangeLog: PR fortran/102458 * gfortran.dg/pr102458b.f90: New test.
Diffstat (limited to 'gcc/fortran/simplify.c')
-rw-r--r--gcc/fortran/simplify.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index b46cbfa..f40e493 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -7471,6 +7471,7 @@ simplify_size (gfc_expr *array, gfc_expr *dim, int k)
mpz_t size;
gfc_expr *return_value;
int d;
+ gfc_ref *ref;
/* For unary operations, the size of the result is given by the size
of the operand. For binary ones, it's the size of the first operand
@@ -7527,6 +7528,10 @@ simplify_size (gfc_expr *array, gfc_expr *dim, int k)
return simplified;
}
+ for (ref = array->ref; ref; ref = ref->next)
+ if (ref->type == REF_ARRAY && ref->u.ar.as)
+ gfc_resolve_array_spec (ref->u.ar.as, 0);
+
if (dim == NULL)
{
if (!gfc_array_size (array, &size))