aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/simplify.c
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2021-11-23 21:39:36 +0100
committerHarald Anlauf <anlauf@gmx.de>2021-11-23 22:02:40 +0100
commit16e95050f71e9fa408e9bd8ccd415b0e7adc66e5 (patch)
tree681a333788af11cdfafca9e03231c6052297ec2c /gcc/fortran/simplify.c
parent4b1d3d8d732bea86c7b2aba46c2a437461020824 (diff)
downloadgcc-16e95050f71e9fa408e9bd8ccd415b0e7adc66e5.zip
gcc-16e95050f71e9fa408e9bd8ccd415b0e7adc66e5.tar.gz
gcc-16e95050f71e9fa408e9bd8ccd415b0e7adc66e5.tar.bz2
Fortran: do not attempt simplification of [LU]BOUND for pointer/allocatable
gcc/fortran/ChangeLog: PR fortran/103392 * simplify.c (simplify_bound): Do not try to simplify LBOUND/UBOUND for arrays with POINTER or ALLOCATABLE attribute. gcc/testsuite/ChangeLog: PR fortran/103392 * gfortran.dg/bound_simplification_7.f90: New test.
Diffstat (limited to 'gcc/fortran/simplify.c')
-rw-r--r--gcc/fortran/simplify.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 6a6b3fb..c9e13b5 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -4266,6 +4266,12 @@ simplify_bound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind, int upper)
|| (as->type == AS_ASSUMED_SHAPE && upper)))
return NULL;
+ /* 'array' shall not be an unallocated allocatable variable or a pointer that
+ is not associated. */
+ if (array->expr_type == EXPR_VARIABLE
+ && (gfc_expr_attr (array).allocatable || gfc_expr_attr (array).pointer))
+ return NULL;
+
gcc_assert (!as
|| (as->type != AS_DEFERRED
&& array->expr_type == EXPR_VARIABLE