https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78942

            Bug ID: 78942
           Summary: Incorrect error message for preprocessed source
           Product: gcc
           Version: 6.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: baradi09 at gmail dot com
  Target Milestone: ---

The line number and the code shown in error messages are inconsistent, when
instead of preprocessing a file on the fly (option -cpp) the file is
preprocessed first (-cpp -E) and then compiled with gfortran.

echo 'program F,AIL' > test.F90; gfortran -cpp test.F90

yields the CORRECT error message:

test.F90:1:7:

 program F,AIL
       1
Error: Invalid form of PROGRAM statement at (1)

While

echo 'program F,AIL' > test.F90; gfortran -cpp -E test.F90 > test.f90; gfortran
test.f90

gives the WRONG error message:

test.f90:1:7:

 # 1 "test.F90"
       1
Error: Invalid form of PROGRAM statement at (1)

The preprocessed file (test.f90) looks as:

# 1 "test.F90"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "test.F90"
program F,AIL

which seems to be correct, though.

Actually, the issue can be cured by changing the first line marker to indicate
an include file, as running gfortran on the modified preprocessed source below
gives the correct error message again:

# 1 "test.F90" 1
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "test.F90"
program F,AIL

Probably the error was introduced in gfortran 5, as the error messages are
consistent in 4.9, but not in 5.1 any more.

This bug may be also related to bug 78792.

Reply via email to