This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: error: "no newline at end of file"


Gabriel Dos Reis <gdr@cs.tamu.edu> writes:

> Florian Weimer <fw@deneb.enyo.de> writes:
> 
> | Neither the C standard nor the C++ standard imposes any requirements
> | on concrete source code representation, so it's not quite right to
> | blame this issue on nonconformant code.
> 
> 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.
> 
> Why is that an issue now?

I don't think we necessarily have to change anything.

But I think that Florian's point is that we don't have to confuse the
concrete implementation with the abstract source representation.  We
could define gcc such that when it sees a concrete file which does not
end in ASCII 0x0a, it automatically appends ASCII 0x0a in the abstract
representation.

This is not inherently different from the way we currently treat
backslash space newline (ASCII 0x5c 0x20 0x0a) as identical to
backslash newline (ASCII 0x5c 0x0a), and treat the newline as being
quoted.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]