aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2022-04-06 22:24:21 +0200
committerHarald Anlauf <anlauf@gmx.de>2022-04-10 20:20:53 +0200
commit54c5e064cc3dc3c9b3dff12b6d48dc3efd482b07 (patch)
tree6633aa668db2ca970144b7d217ffc6f045b1aac1 /gcc/fortran
parent71cac7de8f1285307f921908a43fd864baa543f9 (diff)
downloadgcc-54c5e064cc3dc3c9b3dff12b6d48dc3efd482b07.zip
gcc-54c5e064cc3dc3c9b3dff12b6d48dc3efd482b07.tar.gz
gcc-54c5e064cc3dc3c9b3dff12b6d48dc3efd482b07.tar.bz2
Fortran: fix checking of coshape specification in ALLOCATE statement
gcc/fortran/ChangeLog: PR fortran/105184 * array.cc (match_subscript): Reject assumed size coarray specification with missing lower bound. * resolve.cc (resolve_allocate_expr): Fix logic for checking allocate-coshape-spec in ALLOCATE statement. gcc/testsuite/ChangeLog: PR fortran/105184 * gfortran.dg/coarray_44.f90: Adjust expected output. * gfortran.dg/coarray_allocate_11.f90: Likewise. * gfortran.dg/coarray_allocate_12.f90: New test.
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/array.cc7
-rw-r--r--gcc/fortran/resolve.cc11
2 files changed, 13 insertions, 5 deletions
diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc
index eb9ed85..90ea812 100644
--- a/gcc/fortran/array.cc
+++ b/gcc/fortran/array.cc
@@ -134,6 +134,13 @@ end_element:
if (m == MATCH_ERROR)
return MATCH_ERROR;
+ if (star && ar->start[i] == NULL)
+ {
+ gfc_error ("Missing lower bound in assumed size "
+ "coarray specification at %C");
+ return MATCH_ERROR;
+ }
+
/* See if we have an optional stride. */
if (gfc_match_char (':') == MATCH_YES)
{
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 21c8797..05f8f1b 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -8108,12 +8108,13 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code, bool *array_alloc_wo_spec)
goto failure;
case DIMEN_RANGE:
- if (ar->start[i] == 0 || ar->end[i] == 0)
+ /* F2018:R937:
+ * allocate-coshape-spec is [ lower-bound-expr : ] upper-bound-expr
+ */
+ if (ar->start[i] == 0 || ar->end[i] == 0 || ar->stride[i] != NULL)
{
- /* 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);
+ gfc_error ("Bad coarray specification in ALLOCATE statement "
+ "at %L", &e->where);
goto failure;
}
else if (gfc_dep_compare_expr (ar->start[i], ar->end[i]) == 1)