match
gfc_match_array_ref (gfc_array_ref *ar, gfc_array_spec *as, int init,
- int corank)
+ int corank, bool coarray_only)
{
match m;
bool matched_bracket = false;
matched_bracket = true;
goto coarray;
}
+ else if (coarray_only && corank != 0)
+ goto coarray;
if (gfc_match_char ('(') != MATCH_YES)
{
coarray:
if (!matched_bracket && gfc_match_char ('[') != MATCH_YES)
{
- if (ar->dimen > 0)
+ int dim = coarray_only ? 0 : ar->dimen;
+ if (dim > 0 || coarray_only)
{
if (corank != 0)
{
- for (int i = ar->dimen; i < GFC_MAX_DIMENSIONS; ++i)
+ for (int i = dim; i < GFC_MAX_DIMENSIONS; ++i)
ar->dimen_type[i] = DIMEN_THIS_IMAGE;
ar->codimen = corank;
}
/* array.cc. */
match gfc_match_array_spec (gfc_array_spec **, bool, bool);
-match gfc_match_array_ref (gfc_array_ref *, gfc_array_spec *, int, int);
+match gfc_match_array_ref (gfc_array_ref *, gfc_array_spec *, int, int,
+ bool = false);
match gfc_match_array_constructor (gfc_expr **);
/* interface.cc. */
bool intrinsic;
bool inferred_type;
locus old_loc;
- char sep;
+ char peeked_char;
tail = NULL;
sym->ts.u.derived = tgt_expr->ts.u.derived;
}
- if ((inferred_type && !sym->as && gfc_peek_ascii_char () == '(')
- || (equiv_flag && gfc_peek_ascii_char () == '(')
- || gfc_peek_ascii_char () == '[' || sym->attr.codimension
+ peeked_char = gfc_peek_ascii_char ();
+ if ((inferred_type && !sym->as && peeked_char == '(')
+ || (equiv_flag && peeked_char == '(') || peeked_char == '['
+ || sym->attr.codimension
|| (sym->attr.dimension && sym->ts.type != BT_CLASS
&& !sym->attr.proc_pointer && !gfc_is_proc_ptr_comp (primary)
&& !(gfc_matching_procptr_assignment
|| CLASS_DATA (sym)->attr.codimension)))
{
gfc_array_spec *as;
+ bool coarray_only = sym->attr.codimension && !sym->attr.dimension
+ && sym->ts.type == BT_CHARACTER;
tail = extend_ref (primary, tail);
tail->type = REF_ARRAY;
else
as = sym->as;
- m = gfc_match_array_ref (&tail->u.ar, as, equiv_flag,
- as ? as->corank : 0);
+ m = gfc_match_array_ref (&tail->u.ar, as, equiv_flag, as ? as->corank : 0,
+ coarray_only);
if (m != MATCH_YES)
return m;
gfc_gobble_whitespace ();
+ if (coarray_only)
+ {
+ primary->ts = sym->ts;
+ goto check_substring;
+ }
+
if (equiv_flag && gfc_peek_ascii_char () == '(')
{
tail = extend_ref (primary, tail);
return MATCH_YES;
/* With DEC extensions, member separator may be '.' or '%'. */
- sep = gfc_peek_ascii_char ();
+ peeked_char = gfc_peek_ascii_char ();
m = gfc_match_member_sep (sym);
if (m == MATCH_ERROR)
return MATCH_ERROR;
inquiry = false;
- if (m == MATCH_YES && sep == '%'
- && primary->ts.type != BT_CLASS
+ if (m == MATCH_YES && peeked_char == '%' && primary->ts.type != BT_CLASS
&& (primary->ts.type != BT_DERIVED || inferred_type))
{
match mm;
&& m == MATCH_YES && !inquiry)
{
gfc_error ("Unexpected %<%c%> for nonderived-type variable %qs at %C",
- sep, sym->name);
+ peeked_char, sym->name);
return MATCH_ERROR;
}
if (inquiry)
sym = NULL;
- if (sep == '%')
+ if (peeked_char == '%')
{
if (tmp)
{
if (substring)
primary->ts.u.cl = NULL;
+ if (gfc_peek_ascii_char () == '(')
+ {
+ gfc_error_now ("Unexpected array/substring ref at %C");
+ return MATCH_ERROR;
+ }
break;
case MATCH_NO:
!
subroutine foo
character(:), allocatable :: x[:]
- associate (y => x(:)(2:)) ! { dg-error "Rank mismatch|deferred type parameter" }
- end associate
+ character(:), dimension(:), allocatable :: c[:]
+ associate (y => x(:)(2:)) ! { dg-error "Unexpected array/substring ref|Invalid association target" }
+ end associate ! { dg-error "Expecting END SUBROUTINE" }
+ associate (a => c(:)(:)(2:)) ! { dg-error "Unexpected array/substring ref|Invalid association target" }
+ end associate ! { dg-error "Expecting END SUBROUTINE" }
end
subroutine bar
character(:), allocatable :: x[:]
- associate (y => x(:)(:)) ! { dg-error "Rank mismatch|deferred type parameter" }
- end associate
-end
\ No newline at end of file
+ character(:), allocatable :: c
+
+ associate (y => x(:)(:)) ! { dg-error "Unexpected array/substring ref|Invalid association target" }
+ end associate ! { dg-error "Expecting END SUBROUTINE" }
+ c = x(:)(2:5) ! { dg-error "Unexpected array/substring ref" }
+end