diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Lex/TokenLexer.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Lex/TokenLexer.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/contrib/llvm/tools/clang/lib/Lex/TokenLexer.cpp b/contrib/llvm/tools/clang/lib/Lex/TokenLexer.cpp index e7512fa2831a..c42966928e52 100644 --- a/contrib/llvm/tools/clang/lib/Lex/TokenLexer.cpp +++ b/contrib/llvm/tools/clang/lib/Lex/TokenLexer.cpp @@ -624,21 +624,22 @@ bool TokenLexer::PasteTokens(Token &Tok) { // error. This occurs with "x ## +" and other stuff. Return with Tok // unmodified and with RHS as the next token to lex. if (isInvalid) { + // Explicitly convert the token location to have proper expansion + // information so that the user knows where it came from. + SourceManager &SM = PP.getSourceManager(); + SourceLocation Loc = + SM.createExpansionLoc(PasteOpLoc, ExpandLocStart, ExpandLocEnd, 2); + // Test for the Microsoft extension of /##/ turning into // here on the // error path. if (PP.getLangOpts().MicrosoftExt && Tok.is(tok::slash) && RHS.is(tok::slash)) { - HandleMicrosoftCommentPaste(Tok); + HandleMicrosoftCommentPaste(Tok, Loc); return true; } // Do not emit the error when preprocessing assembler code. if (!PP.getLangOpts().AsmPreprocessor) { - // Explicitly convert the token location to have proper expansion - // information so that the user knows where it came from. - SourceManager &SM = PP.getSourceManager(); - SourceLocation Loc = - SM.createExpansionLoc(PasteOpLoc, ExpandLocStart, ExpandLocEnd, 2); // If we're in microsoft extensions mode, downgrade this from a hard // error to an extension that defaults to an error. This allows // disabling it. @@ -719,7 +720,9 @@ bool TokenLexer::isParsingPreprocessorDirective() const { /// macro, other active macros, and anything left on the current physical /// source line of the expanded buffer. Handle this by returning the /// first token on the next line. -void TokenLexer::HandleMicrosoftCommentPaste(Token &Tok) { +void TokenLexer::HandleMicrosoftCommentPaste(Token &Tok, SourceLocation OpLoc) { + PP.Diag(OpLoc, diag::ext_comment_paste_microsoft); + // We 'comment out' the rest of this macro by just ignoring the rest of the // tokens that have not been lexed yet, if any. |