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)
{
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)
allocate (z(2)[1::2,*]) ! { dg-error "Bad array dimension" }
allocate (z(1::2)[2,*]) ! { dg-error "Bad array specification in ALLOCATE" }
end program pr70071
+
+! { dg-prune-output "Bad coarray specification in ALLOCATE statement" }
program p
integer, allocatable :: z[:,:]
integer :: i
- allocate (z[1:,*]) ! { dg-error "Bad array specification in ALLOCATE statement" }
- allocate (z[:2,*]) ! { dg-error "Bad array specification in ALLOCATE statement" }
+ allocate (z[1:,*]) ! { dg-error "Bad coarray specification in ALLOCATE statement" }
+ allocate (z[:2,*]) ! { dg-error "Bad coarray specification in ALLOCATE statement" }
allocate (z[2:1,*]) ! { dg-error "Upper cobound is less than lower cobound" }
- allocate (z[:0,*]) ! { dg-error "Bad array specification in ALLOCATE statement" }
+ allocate (z[:0,*]) ! { dg-error "Bad coarray specification in ALLOCATE statement" }
allocate (z[0,*]) ! { dg-error "Upper cobound is less than lower cobound" }
allocate (z[1,*]) ! This is OK
allocate (z[1:1,*]) ! This is OK
--- /dev/null
+! { dg-do compile }
+! { dg-options "-fcoarray=single" }
+!
+! PR fortran/105184
+! Based on testcases by Gerhard Steinmetz
+
+program p
+ real, allocatable :: x[:,:]
+ integer :: n = 2
+ allocate (x[ n, *])
+ allocate (x[1:n, *])
+ allocate (x[n:n, *])
+ allocate (x[n, 5:*])
+ allocate (x[ :n, *]) ! { dg-error "Bad coarray specification" }
+ allocate (x[::n, *]) ! { dg-error "Bad coarray specification" }
+ allocate (x[ :1:1, *]) ! { dg-error "Bad coarray specification" }
+ allocate (x[1:n:n, *]) ! { dg-error "Bad coarray specification" }
+ allocate (x[1, : *]) ! { dg-error "Missing lower bound" }
+end