[PATCH] Feature request PR14331: add -W(no-)eof-newline
François-Xavier Coudert
fxcoudert@gmail.com
Tue Apr 10 15:14:00 GMT 2007
I experimented a bit, and the current situation of gfortran wrt files
without a final newline is not very satisfying. Depending on whether
the file is preprocessed or not, we get the warning or not:
$ gfortran a.f90 -W -Wall
$ gfortran a.F90 -W -Wall
a.F90:3: warning: no newline at end of file
(where a.F90 and a.f90 are identical file, with no final newline). If
I read it correctly, your patch doesn't change that behaviour and
doesn't allow the use of -W(no-)eof-newline for the Fortran compiler.
Could you confirm that my reading is correct?
The second question goes to the Fortran folks: I think the Fortran
standard doesn't specify anything about end-of-line characters in
source code, so I guess there's nothing wrong with not having one on
the last line. Do you agree with this? If so, I think we should (once
Dave's patch is committed) pass the -Wno-eof-newline to cc1 when it's
called for preprocessing, to avoid the inconsistency I noted above.
Such a patch will probably look like:
Index: lang-specs.h
===================================================================
--- lang-specs.h (revision 123388)
+++ lang-specs.h (working copy)
@@ -12,6 +12,7 @@
{".FPP", "@f77-cpp-input", 0, 0, 0},
{"@f77-cpp-input",
"cc1 -E -lang-fortran -traditional-cpp -D_LANGUAGE_FORTRAN %(cpp_options) \
+ -Wno-eof-newline \
%{E|M|MM:%(cpp_debug_options)}\
%{!M:%{!MM:%{!E: -o %|.f |\n\
f951 %|.f %{!ffree-form:-ffixed-form} %(cc1_options) %{J*} %{I*}\
@@ -21,6 +22,7 @@
{".F03", "@f95-cpp-input", 0, 0, 0},
{"@f95-cpp-input",
"cc1 -E -lang-fortran -traditional-cpp -D_LANGUAGE_FORTRAN %(cpp_options) \
+ -Wno-eof-newline \
%{E|M|MM:%(cpp_debug_options)}\
%{!M:%{!MM:%{!E: -o %|.f95 |\n\
f951 %|.f95 %{!ffixed-form:-ffree-form} %(cc1_options) %{J*} %{I*}\
(I have no time to build and test it, however).
Thanks for your time and comments,
FX
More information about the Gcc-patches
mailing list