diff options
author | Chris Lattner <sabre@nondot.org> | 2011-06-14 18:19:37 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-06-14 18:19:37 +0000 |
commit | b11e43c31dc5d395a7ec6a07259c078dadd4f47b (patch) | |
tree | fafbc37eefe408fe2fa264b8d1e949d369c7d45f /lib/Lex/TokenLexer.cpp | |
parent | 0e0b6931598be8a50ac5c6e0be595b35da276df9 (diff) |
revert r133003 and fix the bug properly: the issue was that ## in a token
lexer is not a paste operator, it is a normal token. This fixes a conformance
issue shown here:
http://p99.gforge.inria.fr/c99-conformance/c99-conformance-clang-2.9.html
and it defines away the crash from before.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133005 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/TokenLexer.cpp')
-rw-r--r-- | lib/Lex/TokenLexer.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index 751fd0133e..e7cff8bdc3 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/lib/Lex/TokenLexer.cpp @@ -327,7 +327,8 @@ void TokenLexer::Lex(Token &Tok) { bool TokenIsFromPaste = false; // If this token is followed by a token paste (##) operator, paste the tokens! - if (!isAtEnd() && Tokens[CurToken].is(tok::hashhash)) { + // Note that ## is a normal token when not expanding a macro. + if (!isAtEnd() && Tokens[CurToken].is(tok::hashhash) && Macro) { // When handling the microsoft /##/ extension, the final token is // returned by PasteTokens, not the pasted token. if (PasteTokens(Tok)) @@ -487,10 +488,9 @@ bool TokenLexer::PasteTokens(Token &Tok) { // Explicitly convert the token location to have proper instantiation // information so that the user knows where it came from. SourceManager &SM = PP.getSourceManager(); - SourceLocation Loc = PasteOpLoc; - if (InstantiateLocStart.isValid()) - Loc = SM.createInstantiationLoc(Loc, InstantiateLocStart, - InstantiateLocEnd, 2); + SourceLocation Loc = + SM.createInstantiationLoc(PasteOpLoc, InstantiateLocStart, + InstantiateLocEnd, 2); // If we're in microsoft extensions mode, downgrade this from a hard // error to a warning that defaults to an error. This allows // disabling it. |