https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78219

--- Comment #8 from kargl at gcc dot gnu.org ---
(In reply to kargl from comment #7)
> diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
> index d148de3e3b5..d7668f6a928 100644
> --- a/gcc/fortran/match.c
> +++ b/gcc/fortran/match.c
> @@ -2350,6 +2350,34 @@ match_forall_iterator (gfc_forall_iterator **result)
>    gfc_forall_iterator *iter;
>    locus where;
>    match m;
> +  gfc_typespec ts;
> +  bool seen_ts;
> +
> +  /* In Fortran 2018, one can do "forall (integer :: i = 1:20)".

s/2018/2008

> +     Try to match an optional "type-spec ::"  */
> +  seen_ts = false;
> +  gfc_clear_ts (&ts);
> +  m = gfc_match_type_spec (&ts);
> +  if (m == MATCH_YES)
> +    {
> +      seen_ts = (gfc_match (" ::") == MATCH_YES);
> +
> +      if (seen_ts)
> +     {
> +       if (!gfc_notify_std (GFC_STD_F2018, "FORALL includes a "

s/2018/2008

> +                            "type specification at %C"))
> +         return MATCH_ERROR;
> +
> +       if (ts.type != BT_INTEGER)
> +         {
> +           gfc_error ("Type-spec at %L shall be INTEGER",
> +                      &gfc_current_locus);
> +           return MATCH_ERROR;
> +         }
> +     }
> +    }
> +  else if (m == MATCH_ERROR)
> +    return m;
>  
>    where = gfc_current_locus;
>    iter = XCNEW (gfc_forall_iterator);
> @@ -2358,6 +2386,9 @@ match_forall_iterator (gfc_forall_iterator **result)
>    if (m != MATCH_YES)
>      goto cleanup;
>  
> +  if (seen_ts)
> +    iter->var->ts = ts;
> +
>    if (gfc_match_char ('=') != MATCH_YES
>        || iter->var->expr_type != EXPR_VARIABLE)
>      {

Reply via email to