https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81826
Bug ID: 81826 Summary: Incorrect handling of directives left by preprocessor Product: gcc Version: 7.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: raullaasner at gmail dot com Target Milestone: --- I am trying to compile a preprocessed Fortran source file that contains a syntax error: $ cat main.f90 implicit none a = 5 end program $ gfortran -cpp -E main.f90 -o main.f90.pp.f90 $ gfortran main.f90.pp.f90 main.f90.pp.f90:2:3: # 1 "<built-in>" 1 Error: Symbol ‘a’ at (1) has no IMPLICIT type The problem is that the error message refers to the preprocessed file and not the original source file. Also, it is showing an incorrect line above the number "1", which should be the offending line. This is unlike the C compiler: $ cat main.c int main() // { return 0; } $ gcc -E main.c -o main.c.pp.c $ gcc main.c.pp.c main.c: In function ‘main’: main.c:2:3: error: expected declaration specifiers before ‘return’ return 0; ^~~~~~ main.c:3:1: error: expected declaration specifiers before ‘}’ token } ^ main.c:3:1: error: expected ‘{’ at end of input where the error message refers to the correct source file (main.c:2:3). This issue was brought up at https://gitlab.kitware.com/cmake/cmake/issues/17160#note_301744 and it inhibits the correct behavior of CMake with the Ninja generator.