http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53993

             Bug #: 53993
           Summary: gfortran ignores file part of #line directives
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: mg1...@web.de


Created attachment 27810
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27810
Example files to reproduce bug

#line directives inserted by source-code preprocessors are only partially
handled by gfortran. The line number part is OK, the file name part is ignored
and the input file name is used instead. This can mess up the debug information
of preprocessed Fortran files.

Example:
- The file 'dummy.f90' in the attached tar archive provides a simple Fortran
  code, calling a subroutine from the main program which prints "Hello world!".
  Compilation with gfortran 4.7.1 yields the following result:

  % gfortran -g -c dummy.f90
  % nm -l dummy.o
  000000000000006d t MAIN__    /tmp/bug/dummy.f90:1
                   U _gfortran_set_args    /tmp/bug/dummy.f90:3
                   U _gfortran_set_options    /tmp/bug/dummy.f90:3
                   U _gfortran_st_write    /tmp/bug/dummy.f90:6
                   U _gfortran_st_write_done    /tmp/bug/dummy.f90:6
                   U _gfortran_transfer_character_write    /tmp/bug/dummy.f90:6
  0000000000000000 T foo_    /tmp/bug/dummy.f90:5
  0000000000000078 T main    /tmp/bug/dummy.f90:3
  0000000000000020 r options.1.1854

- Suppose a source-code preprocessor inserts write statements to mark the
  begin and end of the main program as well as #line directives to account
  for modified line numbers and file name (prospective output provided as
  'dummy.mod.F90').

  % gfortran -g -c dummy.mod.F90
  % nm -l dummy.mod.o
  000000000000006d t MAIN__    /tmp/bug/dummy.mod.F90:1
                   U _gfortran_set_args    /tmp/bug/dummy.mod.F90:3
                   U _gfortran_set_options    /tmp/bug/dummy.mod.F90:3
                   U _gfortran_st_write    /tmp/bug/dummy.mod.F90:6
                   U _gfortran_st_write_done    /tmp/bug/dummy.mod.F90:6
                   U _gfortran_transfer_character_write   
/tmp/bug/dummy.mod.F90:6
  0000000000000000 T foo_    /tmp/bug/dummy.mod.F90:5
  000000000000013f T main    /tmp/bug/dummy.mod.F90:3
  0000000000000040 r options.3.1856

- As can be seen, the line number information provided by the #line directives
  is handled correctly, however, the file name refers to the actual input file
  instead of the file specified by the directive.

This bug seems to only affect Fortran, similar examples in C/C++ work fine.
This behavior has been verified with GCC 4.5.3, 4.6.2 and 4.7.1.

Reply via email to