diff options
author | dim <dim@FreeBSD.org> | 2010-09-17 15:54:40 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2010-09-17 15:54:40 +0000 |
commit | 36c49e3f258dced101949edabd72e9bc3f1dedc4 (patch) | |
tree | 0bbe07708f7571f8b5291f6d7b96c102b7c99dee /lib/Lex/TokenLexer.cpp | |
parent | fc84956ac8b7cd244ef30e7a4d4d38a58dec5904 (diff) | |
download | FreeBSD-src-36c49e3f258dced101949edabd72e9bc3f1dedc4.zip FreeBSD-src-36c49e3f258dced101949edabd72e9bc3f1dedc4.tar.gz |
Vendor import of clang r114020 (from the release_28 branch):
http://llvm.org/svn/llvm-project/cfe/branches/release_28@114020
Approved by: rpaulo (mentor)
Diffstat (limited to 'lib/Lex/TokenLexer.cpp')
-rw-r--r-- | lib/Lex/TokenLexer.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index 56bb073..94719b0 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/lib/Lex/TokenLexer.cpp @@ -268,6 +268,13 @@ void TokenLexer::ExpandFunctionArguments() { // Remove the paste operator, report use of the extension. PP.Diag(ResultToks.back().getLocation(), diag::ext_paste_comma); ResultToks.pop_back(); + + // If the comma was right after another paste (e.g. "X##,##__VA_ARGS__"), + // then removal of the comma should produce a placemarker token (in C99 + // terms) which we model by popping off the previous ##, giving us a plain + // "X" when __VA_ARGS__ is empty. + if (!ResultToks.empty() && ResultToks.back().is(tok::hashhash)) + ResultToks.pop_back(); } continue; } @@ -478,7 +485,7 @@ bool TokenLexer::PasteTokens(Token &Tok) { return true; } - // Do not emit the warning when preprocessing assembler code. + // Do not emit the error when preprocessing assembler code. if (!PP.getLangOptions().AsmPreprocessor) { // Explicitly convert the token location to have proper instantiation // information so that the user knows where it came from. @@ -486,8 +493,13 @@ bool TokenLexer::PasteTokens(Token &Tok) { SourceLocation Loc = SM.createInstantiationLoc(PasteOpLoc, InstantiateLocStart, InstantiateLocEnd, 2); - PP.Diag(Loc, diag::err_pp_bad_paste) - << std::string(Buffer.begin(), Buffer.end()); + // 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. + PP.Diag(Loc, + PP.getLangOptions().Microsoft ? diag::err_pp_bad_paste_ms + : diag::err_pp_bad_paste) + << Buffer.str(); } // Do not consume the RHS. |