[Bug fortran/88248] [F18] Bogus warning about obsolescent feature: Labeled DO statement

kargl at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Dec 22 05:28:00 GMT 2018


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

--- Comment #5 from kargl at gcc dot gnu.org ---
(In reply to kargl from comment #4)
> (In reply to G. Steinmetz from comment #0)
> > Branching out via END=, ERR= or EOR= specifier in combination with
> > CONTINUE is interpreted as a labeled DO loop. Option -std=f2018 
> > misleadingly flags this with a warning -- (low prio).
> > 
> > 
> > $ cat z1.f90
> > program p
> >    do
> >       rewind (1, err=99)
> >    end do
> > 99 continue
> > end
> >

(snip)

> > 
> > $ gfortran-9-20181125 -c z1.f90 -std=f2008
> > $
> > $ gfortran-9-20181125 -c z1.f90 -std=f2018
> > z1.f90:5:2:
> > 
> >     5 | 99 continue
> >       |  1
> > Warning: Fortran 2018 obsolescent feature: Labeled DO statement at (1)
> 
> The warning was added by Janus in r260705.  I'll need to look
> deeper, but I don't think there is an easy way to distinguish
> between a labeled statement used as do-loop terminator and 
> a ordinary labeled statement.

Branching to any labeled CONTINUE statement will issue the warning.

program foo
   x = 42
   if (x < 0) goto 10
   goto 20
   print *, x
10 continue
   x = x + 1
20 continue
   x = x - 1
end program foo

% gfcx -std=f2018 -c a.f90
a.f90:6:2:

    6 | 10 continue
      |  1
Warning: Fortran 2018 obsolescent feature: Labeled DO statement at (1)
a.f90:8:2:

    8 | 20 continue
      |  1
Warning: Fortran 2018 obsolescent feature: Labeled DO statement at (1)

There isn't a do-loop in the code.  The offending part of
r260705 should be removed as it cannot be easily fixed.


More information about the Gcc-bugs mailing list