summaryrefslogtreecommitdiffstats
path: root/lib/Lex/TokenLexer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Lex/TokenLexer.cpp')
-rw-r--r--lib/Lex/TokenLexer.cpp18
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.
OpenPOWER on IntegriCloud