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. Jeff