This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: error: "no newline at end of file"
"Zack Weinberg" <zackw@panix.com> writes:
| Gabriel Dos Reis wrote:
| > I don't understand your statement. The C++ (and the C) standard says
| >
| > # If a source file that is not empty does not end in a new-line
| > # character, or ends in a new-line character immediately preceded by a
| > # backslash character, the behavior is undefined.
| >
| > The GNU preprocessor has chosen to diagnose that for ages.
|
| That text as part of the C standard *doesn't* call for a mandatory
| diagnostic, though (it is not a violation of a "shall" phrase in a
| "constraints" section).
I was very careful in saying that the GNU preprocessor *has chosen*
(as opposed to a diagnostic is required), to emit a diagnostic --
overall, I think it is a good thing. However, whether it should be a
hard error or a warning I have no preference.
What I did suggest, which turned out to be invalid, was that a pedwarn
in C++ is a warning unless -pedantic. That was changed by a patch
committed in 1998.
If the new-line ending rule is found to be unacceptable (my editor
always asks if I wanted to add one, so I did not get to realize adding
one is too much), your suggestion:
| In this particular case, I think we should downgrade from
| CPP_DL_PEDWARN to CPP_DL_WARNING, because it's not mandatory (at least
| in C) and it's a totally harmless thing to do.
is fine -- I don't know who of you or Neil added the diagnostic
classification -- as you're "morally" the CPP maintainer (we are
missing one).
-- Gaby