}
if (gfc_match_char (':') == MATCH_YES)
- return AS_DEFERRED;
+ {
+ locus old_loc = gfc_current_locus;
+ if (gfc_match_char ('*') == MATCH_YES)
+ {
+ /* F2018:R821: "assumed-implied-spec is [ lower-bound : ] *". */
+ gfc_error ("A lower bound must precede colon in "
+ "assumed-size array specification at %L", &old_loc);
+ return AS_UNKNOWN;
+ }
+ else
+ {
+ return AS_DEFERRED;
+ }
+ }
m = gfc_match_expr (upper);
if (m == MATCH_NO)
{
as->rank++;
current_type = match_array_element_spec (as);
+ if (current_type == AS_UNKNOWN)
+ goto cleanup;
/* Note that current_type == AS_ASSUMED_SIZE for both assumed-size
and implied-shape specifications. If the rank is at least 2, we can
if (as->rank == 1)
{
- if (current_type == AS_UNKNOWN)
- goto cleanup;
as->type = current_type;
}
else
--- /dev/null
+! { dg-do compile }
+! { dg-options "-fcoarray=lib" }
+! PR fortran/102180 - Improve checking of assumed size array spec
+
+subroutine s(x,y)
+ real :: x(0:*) ! legal
+ real :: y[0:*] ! legal
+end
+
+subroutine t(x,y)
+ real :: x(:*) ! { dg-error "A lower bound must precede colon" }
+ real :: y[:*] ! { dg-error "A lower bound must precede colon" }
+end
+
+subroutine u(x,y,z)
+ real :: x(2,*)
+ real :: y(2,2:*)
+ real :: z(2,:*) ! { dg-error "A lower bound must precede colon" }
+end