diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-19 20:29:42 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-19 20:29:42 +0000 |
commit | 1c1a00cf51e5293e596e90d5c29a11c85197d996 (patch) | |
tree | 6e9330518b01e932d6838a5eea9e36f53059a5da /clang/lib/Lex/TokenLexer.cpp | |
parent | 08a375b9542cec2bfb065bc5332d6e7329cbcf20 (diff) | |
download | bcm5719-llvm-1c1a00cf51e5293e596e90d5c29a11c85197d996.tar.gz bcm5719-llvm-1c1a00cf51e5293e596e90d5c29a11c85197d996.zip |
move token paste poisoning diagnostics to after the instantiation loc
for a token is set, this makes the diagnostic "expanded from stack" work
for this diagnostic. Add a testcase for PR3918.
llvm-svn: 69544
Diffstat (limited to 'clang/lib/Lex/TokenLexer.cpp')
-rw-r--r-- | clang/lib/Lex/TokenLexer.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp index 8cec4332217..7ff473f090b 100644 --- a/clang/lib/Lex/TokenLexer.cpp +++ b/clang/lib/Lex/TokenLexer.cpp @@ -308,13 +308,18 @@ void TokenLexer::Lex(Token &Tok) { // Get the next token to return. Tok = Tokens[CurToken++]; + bool TokenIsFromPaste = false; + // If this token is followed by a token paste (##) operator, paste the tokens! if (!isAtEnd() && Tokens[CurToken].is(tok::hashhash)) if (PasteTokens(Tok)) { // When handling the microsoft /##/ extension, the final token is // returned by PasteTokens, not the pasted token. return; + } else { + TokenIsFromPaste = true; } + // The token's current location indicate where the token was lexed from. We // need this information to compute the spelling of the token, but any @@ -342,6 +347,17 @@ void TokenLexer::Lex(Token &Tok) { // turning "for" into a keyword. Tok.setKind(II->getTokenID()); + // If this identifier was poisoned and from a paste, emit an error. This + // won't be handled by Preprocessor::HandleIdentifier because this is coming + // from a macro expansion. + if (II->isPoisoned() && TokenIsFromPaste) { + // 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); + } + if (!DisableMacroExpansion && II->isHandleIdentifierCase()) PP.HandleIdentifier(Tok); } @@ -476,17 +492,6 @@ bool TokenLexer::PasteTokens(Token &Tok) { // by saying we're skipping contents, so we need to do this manually. 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; } |