aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Lex')
-rw-r--r--lib/Lex/MacroArgs.cpp1
-rw-r--r--lib/Lex/PPMacroExpansion.cpp5
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/Lex/MacroArgs.cpp b/lib/Lex/MacroArgs.cpp
index 2646a61e51..cba69b7d79 100644
--- a/lib/Lex/MacroArgs.cpp
+++ b/lib/Lex/MacroArgs.cpp
@@ -72,6 +72,7 @@ const Token *MacroArgs::getUnexpArgument(unsigned Arg) const {
if (Result->is(tok::eof))
--Arg;
}
+ assert(Result < Start+NumUnexpArgTokens && "Invalid arg #");
return Result;
}
diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp
index 48c166daba..18dcfb25e7 100644
--- a/lib/Lex/PPMacroExpansion.cpp
+++ b/lib/Lex/PPMacroExpansion.cpp
@@ -427,6 +427,11 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
Tok.setLocation(EndLoc);
Tok.setLength(0);
ArgTokens.push_back(Tok);
+
+ // If we expect two arguments, add both as empty.
+ if (NumActuals == 0 && MinArgsExpected == 2)
+ ArgTokens.push_back(Tok);
+
} else if (NumActuals > MinArgsExpected && !MI->isVariadic()) {
// Emit the diagnostic at the macro name in case there is a missing ).
// Emitting it at the , could be far away from the macro name.