This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Using the #line directive with gfortran
- From: marco restelli <mrestelli at gmail dot com>
- To: fortran at gcc dot gnu dot org
- Date: Tue, 23 May 2017 15:44:51 +0200
- Subject: Using the #line directive with gfortran
- Authentication-results: sourceware.org; auth=none
- Reply-to: mrestelli at gmail dot com
Hi all,
I am confused by the treatment of the #line directive by gfortran.
Suppose that I have two files:
file_a.xyz:
program test
implicit none
integer :: i
<some lines consumed by a preprocessor>
<some lines consumed by a preprocessor>
<some lines consumed by a preprocessor>
<some lines consumed by a preprocessor>
j = 3
end program
! comments
! other comments
! ...
! more comments
file_b.F90
program test
implicit none
integer :: i
#line 8 "file_a.xyz"
j = 3
end program
! comments
! other comments
! ...
! more comments
The idea is that file_b.F90 comes from a preprocessing of file_a.xyz,
so all the compiler diagnostics should be referred to file_a.xyz.
Compiling file_b.F90 I see
$ gfortran -c file_b.F90 -o file_b.o
file_b.F90:8:2:
! other comments
1
Error: Symbol ‘j’ at (1) has no IMPLICIT type
So it seems that only the line number "8" is used by gfortran, but not
the file name: both the file name and the source line in fact are
referring to file_b.F90. I would like a message like
$ gfortran -c file_b.F90 -o file_b.o
file_a.xyz:8:2:
j = 3
1
Error: Symbol ‘j’ at (1) has no IMPLICIT type
(By the way, gcc on C code behaves like I would expect, showing the
name and the source line of the original file file_a.xyz.)
Is there a way to have this output from gfortran?
Thank,
Marco