This is the mail archive of the gcc-patches@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: Patch to fix handling of incomplete header names


"Joseph S. Myers" <jsm@polyomino.org.uk> writes:

> The C standard defines how a source file is lexed into preprocessing
> tokens by a greedy algorithm; there is no such thing as a partial
> preprocessing token.  Unmatched quotes yield undefined behavior
> (because a single ' or " character as a token is specified as doing
> so) so actually implementing the lexing to make ' or " a single token
> isn't needed, but there is no such laxity in header names <... (with
> missing >).  Zack said in a previous discussion on comp.std.c
> <http://groups.google.com/groups?selm=9csqt9%24omd%241%40nntp.Stanford.EDU>
> that "major architectural changes" would be needed for this to work.
> This no longer seems to be the case; the following simple patch
> implements the required semantics.
>
> Bootstrapped with no regressions on i686-pc-linux-gnu.  OK to commit
> to mainline and 3.4 branch (first two cases in the testcase are
> regressions from 2.95)?
>
> 2004-02-05  Joseph S. Myers  <jsm@polyomino.org.uk>
>
> 	* cpplex.c (lex_string): Return a CPP_LESS token for missing '>'
> 	in a header name.
> 	(_cpp_lex_direct): Handle this.
>
> testsuite:
> 2004-02-05  Joseph S. Myers  <jsm@polyomino.org.uk>
>
> 	* gcc.dg/cpp/include4.c: New test.

It is still my opinion that this should not be valid C, even though it
presently is.

You can check the patch in if and only if you file a defect report
proposing the changes outlined in
http://groups.google.com/groups?selm=9e4ejk%24d06%241%40nntp.Stanford.EDU

(probably best to use arguments along the lines of the third paragraph
of new text in 
http://groups.google.com/groups&selm=9emd9t%24d3k%241%40nntp.Stanford.EDU
 - inconsistency with other "things that act like string constants)

zw


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