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

--- Comment #3 from Thomas Fanning <thfanning at gmail dot com> ---
In gcc-4.9.2, using both -M and -E produce the expected output: dependencies
only. But in gfortran, both preprocessed output and dependencies are produced.
This is incorrect.

It seems to me that the gfortran driver is not setting up the preprocessing
environment correctly, so I'm not sure this is strictly a preprocessor problem.

For the following C code: preprocess.c

  // It's me!
  #include "UTIL_System.h"

  int main()
  {
    return 0;
  }

gcc -M preprocess.c
--> preprocess.o: preprocess.c UTIL_System.h  <-- dependencies

gcc -M -E preprocess.c
--> preprocess.o: preprocess.c UTIL_System.h  <-- dependencies

Since GNU make defines CPP = '$(CC) -E', it is essential that combining -E and
-M are compatible.

For the following gfortran file however: preprocess.F90

  ! It's me!
  program test
  #include "UTIL_System.h"
  print *, "Hello, World!"
  end program

gfortran -M preprocess.F90
--> preprocess.o: preprocess.F90 UTIL_System.h  <-- dependencies

But gfortran -M -E preprocess.F90
--> # 1 "preprocess.F90"
--> # 1 "<built-in>"
--> # 1 "<command-line>"
--> # 1 "preprocess.F90"
--> ! It's me!
--> program test
--> 
--> # 1 "UTIL_System.h" 1
--> # 4 "preprocess.F90" 2
--> print *, "Hello, World!"
--> end program
--> preprocess.o: preprocess.F90 UTIL_System.h  <-- dependencies

Reply via email to