[Bug fortran/102371] Error for type spec in FORALL statement

sgk at troutmask dot apl.washington.edu gcc-bugzilla@gcc.gnu.org
Tue Sep 21 21:32:49 GMT 2021


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

--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Sep 21, 2021 at 08:05:02PM +0000, anlauf at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102371
> 
> anlauf at gcc dot gnu.org changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>              Status|NEW                         |RESOLVED
>          Resolution|---                         |DUPLICATE
>                  CC|                            |anlauf at gcc dot gnu.org
> 
> --- Comment #2 from anlauf at gcc dot gnu.org ---
> It is indeed a duplicate of pr78219.
> 
> Unfortunately the patch provided there fails on the present testcase with:
> 
> pr102371.f90:7:27:
> 
>     7 |   forall(integer(long) :: i=1:very_large, j=1:2)
>       |                           1
> Error: Symbol 'i' at (1) has no IMPLICIT type
> pr102371.f90:7:43:

Ugh, I forgot that one could chain forall iterators like above.
The patch is in match_forall_iterator(), which is called multiple
times in match_forall_header().  Specifically,  lines 2428-2443.

  m = match_forall_iterator (&new_iter);       <<<<< grabs typespec
  if (m == MATCH_ERROR)
    goto cleanup;
  if (m == MATCH_NO)
    goto syntax;

  head = tail = new_iter;

  for (;;)
    {
      if (gfc_match_char (',') != MATCH_YES)
        break;

      m = match_forall_iterator (&new_iter);  <<<<< typespec gone
      if (m == MATCH_ERROR)
        goto cleanup;


The patch can likely to be right before line 2428 and then
after if "(m == MATCH_YES and seen_ts)" fix-up the new_iter
typespec.


More information about the Gcc-bugs mailing list