This is the mail archive of the 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" <> 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
> <>
> 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  <>
> 	* 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  <>
> 	* 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

(probably best to use arguments along the lines of the third paragraph
of new text in
 - inconsistency with other "things that act like string constants)


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