aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/check.cc
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2023-05-21 22:25:29 +0200
committerHarald Anlauf <anlauf@gmx.de>2023-05-24 21:51:02 +0200
commit5fd5d8fb744fd9251d04e4b17d04f2340e6a283b (patch)
tree9ee11c528359762ed26cfdcba196f8641fb1811f /gcc/fortran/check.cc
parentefd2b55d8562c6e80cb7ee8b9b1f9418f0c00cd9 (diff)
downloadgcc-5fd5d8fb744fd9251d04e4b17d04f2340e6a283b.zip
gcc-5fd5d8fb744fd9251d04e4b17d04f2340e6a283b.tar.gz
gcc-5fd5d8fb744fd9251d04e4b17d04f2340e6a283b.tar.bz2
Fortran: checking and simplification of RESHAPE intrinsic [PR103794]
gcc/fortran/ChangeLog: PR fortran/103794 * check.cc (gfc_check_reshape): Expand constant arguments SHAPE and ORDER before checking. * gfortran.h (gfc_is_constant_array_expr): Add prototype. * iresolve.cc (gfc_resolve_reshape): Expand constant argument SHAPE. * simplify.cc (is_constant_array_expr): If array is determined to be constant, expand small array constructors if needed. (gfc_is_constant_array_expr): Wrapper for is_constant_array_expr. (gfc_simplify_reshape): Fix check for insufficient elements in SOURCE when no padding specified. gcc/testsuite/ChangeLog: PR fortran/103794 * gfortran.dg/reshape_10.f90: New test. * gfortran.dg/reshape_11.f90: New test.
Diffstat (limited to 'gcc/fortran/check.cc')
-rw-r--r--gcc/fortran/check.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc
index 3dd1711..4086dc7 100644
--- a/gcc/fortran/check.cc
+++ b/gcc/fortran/check.cc
@@ -4723,7 +4723,7 @@ gfc_check_reshape (gfc_expr *source, gfc_expr *shape,
}
gfc_simplify_expr (shape, 0);
- shape_is_const = gfc_is_constant_expr (shape);
+ shape_is_const = gfc_is_constant_array_expr (shape);
if (shape->expr_type == EXPR_ARRAY && shape_is_const)
{
@@ -4732,6 +4732,8 @@ gfc_check_reshape (gfc_expr *source, gfc_expr *shape,
for (i = 0; i < shape_size; ++i)
{
e = gfc_constructor_lookup_expr (shape->value.constructor, i);
+ if (e == NULL)
+ break;
if (e->expr_type != EXPR_CONSTANT)
continue;
@@ -4764,7 +4766,7 @@ gfc_check_reshape (gfc_expr *source, gfc_expr *shape,
if (!type_check (order, 3, BT_INTEGER))
return false;
- if (order->expr_type == EXPR_ARRAY && gfc_is_constant_expr (order))
+ if (order->expr_type == EXPR_ARRAY && gfc_is_constant_array_expr (order))
{
int i, order_size, dim, perm[GFC_MAX_DIMENSIONS];
gfc_expr *e;