[RFA][fortran] Fix # <line> <file> handling in the Fortran front-end
Steve Kargl
sgk@troutmask.apl.washington.edu
Fri May 4 20:09:00 GMT 2018
On Fri, May 04, 2018 at 02:05:11PM -0600, Jeff Law wrote:
> On 05/04/2018 01:55 PM, Steve Kargl wrote:
> > On Fri, May 04, 2018 at 01:32:00PM -0600, Jeff Law wrote:
> >>
> >> The Fortran front end has its own code to parse # <line> <file>
> >> directives. We've run into a case where it does not function correctly.
> >> In particular when the directive changes the current file, subsequent
> >> diagnostics still refer to the original filename.
> >>
> >> Concretely take this code and compile it with -Wall:
> >>
> >> # 12345 "foo-f"
> >> SUBROUTINE s(dummy)
> >> INTEGER, INTENT(in) :: dummy
> >> END SUBROUTINE
> >
> > Can you tell us where the above comes from?
> Use of # <line> <file> is a standard CPP directive one can use to change
> the compiler's notion of file/line. It's defined by ISO for C/C++ and
> appears to be relatively common in other Fortran compilers. GNU Fortran
> tries to handle it and just gets it slightly wrong.
>
> It's most typically used when source code is generated by another program.
>
> > If I have the three lines of code in a file
> > name 'a.inc', and use either the Fortran
> > INCLUDE statement or a cpp #include statement
> > I get what I expect.
> Right. That uses a slightly different form internally. It'll get
> turned into
>
> # <line> <file> <flags>
>
> Where the flags will indicate entry/exit from included files. That form
> is handled correctly by the GNU Fortran front end. But this form is not
> for external use.
Thanks for the explanation. The patch looks good to me.
--
Steve
More information about the Fortran
mailing list