diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-19 20:06:32 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-19 20:06:32 +0000 |
commit | 88e43a519e5ecc06b5e14da8ffb1e89cc15474c0 (patch) | |
tree | 79d3cc79ac23f56f0f9abf8c1774993dd42c87fc /lib/Lex/TokenLexer.cpp | |
parent | d1bd7fc4cd88f8790c56620d22560e19717f468a (diff) |
Fix PR3918: Invalid use of __VA_ARGS__ not diagnosed,
by rejecting invalid poisoned tokens in the token
pasting path.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69536 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/TokenLexer.cpp')
-rw-r--r-- | lib/Lex/TokenLexer.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index ec48690b35..8cec433221 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/lib/Lex/TokenLexer.cpp @@ -457,7 +457,6 @@ bool TokenLexer::PasteTokens(Token &Tok) { // operator. if (Result.is(tok::hashhash)) Result.setKind(tok::unknown); - // FIXME: Turn __VA_ARGS__ into "not a token"? } // Transfer properties of the LHS over the the Result. @@ -475,7 +474,19 @@ bool TokenLexer::PasteTokens(Token &Tok) { if (Tok.is(tok::identifier)) { // Look up the identifier info for the token. We disabled identifier lookup // by saying we're skipping contents, so we need to do this manually. - Tok.setIdentifierInfo(PP.LookUpIdentifierInfo(Tok, ResultTokStrPtr)); + IdentifierInfo *II = PP.LookUpIdentifierInfo(Tok, ResultTokStrPtr); + Tok.setIdentifierInfo(II); + + // If this identifier was poisoned, emit an error. This won't be handled by + // Preprocessor::HandleIdentifier because this is coming from a macro + // expansion. + if (II->isPoisoned()) { + // We warn about __VA_ARGS__ with poisoning. + if (II->isStr("__VA_ARGS__")) + PP.Diag(Tok, diag::ext_pp_bad_vaargs_use); + else + PP.Diag(Tok, diag::err_pp_used_poisoned_id); + } } return false; } |