aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/resolve.c
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2019-03-03 13:16:40 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2019-03-03 13:16:40 +0000
commitb450b08dfb78d46a64fe73ac4a6ce3aad9ce4baf (patch)
treecccf2db0c923a7abffdc02dd3d27f3276afc88ea /gcc/fortran/resolve.c
parent4a1a6fd764f2f8a6535a5f4ab82688cc652a141a (diff)
downloadgcc-b450b08dfb78d46a64fe73ac4a6ce3aad9ce4baf.zip
gcc-b450b08dfb78d46a64fe73ac4a6ce3aad9ce4baf.tar.gz
gcc-b450b08dfb78d46a64fe73ac4a6ce3aad9ce4baf.tar.bz2
re PR fortran/72714 ([Coarray] ICE in gfc_array_init_size, at fortran/trans-array.c:5235)
2019-03-03 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/72714 * resolve.c (resolve_allocate_expr): Add some tests for coarrays. 2019-03-03 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/72714 * gfortran.dg/coarray_allocate_11.f90: New test. From-SVN: r269352
Diffstat (limited to 'gcc/fortran/resolve.c')
-rw-r--r--gcc/fortran/resolve.c53
1 files changed, 47 insertions, 6 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 422cec2..955978b 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -7766,13 +7766,54 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code, bool *array_alloc_wo_spec)
if (codimension)
for (i = ar->dimen; i < ar->dimen + ar->codimen; i++)
- if (ar->dimen_type[i] == DIMEN_THIS_IMAGE)
- {
- gfc_error ("Coarray specification required in ALLOCATE statement "
- "at %L", &e->where);
- goto failure;
- }
+ {
+ switch (ar->dimen_type[i])
+ {
+ case DIMEN_THIS_IMAGE:
+ gfc_error ("Coarray specification required in ALLOCATE statement "
+ "at %L", &e->where);
+ goto failure;
+
+ case DIMEN_RANGE:
+ if (ar->start[i] == 0 || ar->end[i] == 0)
+ {
+ /* If ar->stride[i] is NULL, we issued a previous error. */
+ if (ar->stride[i] == NULL)
+ gfc_error ("Bad array specification in ALLOCATE statement "
+ "at %L", &e->where);
+ goto failure;
+ }
+ else if (gfc_dep_compare_expr (ar->start[i], ar->end[i]) == 1)
+ {
+ gfc_error ("Upper cobound is less than lower cobound at %L",
+ &ar->start[i]->where);
+ goto failure;
+ }
+ break;
+
+ case DIMEN_ELEMENT:
+ if (ar->start[i]->expr_type == EXPR_CONSTANT)
+ {
+ gcc_assert (ar->start[i]->ts.type == BT_INTEGER);
+ if (mpz_cmp_si (ar->start[i]->value.integer, 1) < 0)
+ {
+ gfc_error ("Upper cobound is less than lower cobound "
+ " of 1 at %L", &ar->start[i]->where);
+ goto failure;
+ }
+ }
+ break;
+
+ case DIMEN_STAR:
+ break;
+ default:
+ gfc_error ("Bad array specification in ALLOCATE statement at %L",
+ &e->where);
+ goto failure;
+
+ }
+ }
for (i = 0; i < ar->dimen; i++)
{
if (ar->type == AR_ELEMENT || ar->type == AR_FULL)