aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/simplify.c
diff options
context:
space:
mode:
authorMark Eggleston <markeggleston@gcc.gnu.org>2020-02-24 15:40:03 +0000
committerMark Eggleston <markeggleston@gcc.gnu.org>2020-02-24 15:40:03 +0000
commit27bf39a8035445ffc71b551619d7c1a232498054 (patch)
tree8285da0bc6ad45669e4ac48e03a9d21cddc3833e /gcc/fortran/simplify.c
parentb07c085581eb98cde408d9583ee17d58832826ae (diff)
downloadgcc-27bf39a8035445ffc71b551619d7c1a232498054.zip
gcc-27bf39a8035445ffc71b551619d7c1a232498054.tar.gz
gcc-27bf39a8035445ffc71b551619d7c1a232498054.tar.bz2
ortran: ICE using SHAPE with FINDLOC PR93835
The expression representing the array returned by SHAPE does not have its shape defined. An ICE occurs when FINDLOC attempts to use the shape of the array. Add shape to expression before returning from SHAPE. Whitespace issues identified by Steven G. Kargl <kargl@gcc.gnu.org> have also been fixed. gcc/fortran/ChangeLog PR fortran/93835 * simplify.c (simplify_findloc_nodim) : Fix whitespace issues. (gfc_simplify_shape) : Create and initialise one shape value for the result expression. Set shape value with the rank of the source array. gcc/testsuite/ChangeLog PR fortran/93835 * gfortran.dg/pr77351.f90 : Check for one error instead of two. * gfortran.dg/pr93835.f08 : New test.
Diffstat (limited to 'gcc/fortran/simplify.c')
-rw-r--r--gcc/fortran/simplify.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 613fdaf..86715d5 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -5497,7 +5497,7 @@ simplify_findloc_nodim (gfc_expr *result, gfc_expr *value, gfc_expr *array,
bool continue_loop;
bool ma;
- for (i = 0; i<array->rank; i++)
+ for (i = 0; i < array->rank; i++)
res[i] = -1;
/* Shortcut for constant .FALSE. MASK. */
@@ -5540,7 +5540,7 @@ simplify_findloc_nodim (gfc_expr *result, gfc_expr *value, gfc_expr *array,
if (ma && gfc_compare_expr (a, value, INTRINSIC_EQ) == 0)
{
- for (i = 0; i<array->rank; i++)
+ for (i = 0; i < array->rank; i++)
res[i] = count[i];
if (!back_val)
goto finish;
@@ -5565,9 +5565,9 @@ simplify_findloc_nodim (gfc_expr *result, gfc_expr *value, gfc_expr *array,
} while (count[n] == extent[n]);
}
- finish:
+finish:
result_ctor = gfc_constructor_first (result->value.constructor);
- for (i = 0; i<array->rank; i++)
+ for (i = 0; i < array->rank; i++)
{
gfc_expr *r_expr;
r_expr = result_ctor->expr;
@@ -7228,6 +7228,8 @@ gfc_simplify_shape (gfc_expr *source, gfc_expr *kind)
return NULL;
result = gfc_get_array_expr (BT_INTEGER, k, &source->where);
+ result->shape = gfc_get_shape (1);
+ mpz_init (result->shape[0]);
if (source->rank == 0)
return result;
@@ -7284,6 +7286,8 @@ gfc_simplify_shape (gfc_expr *source, gfc_expr *kind)
if (t)
gfc_clear_shape (shape, source->rank);
+ mpz_set_si (result->shape[0], source->rank);
+
return result;
}