fix PR3880, fixing a comma swallowing bug handling macros that only take

... arguments.

llvm-svn: 67706
This commit is contained in:
Chris Lattner 2009-03-25 21:08:24 +00:00
parent beb9055000
commit 51a53f92a5
2 changed files with 11 additions and 0 deletions

View File

@ -403,6 +403,12 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
Tok.setLocation(EndLoc);
Tok.setLength(0);
ArgTokens.push_back(Tok);
} else if (NumActuals == 1 && ArgTokens.size() == 1) {
// If there is exactly one argument, and that argument is just an EOF token,
// then we have an empty "()" argument empty list. This is fine, even if
// the macro expects one argument (the argument is just empty). However, if
// the macro expects "...", then we need to know that it was elided.
isVarargsElided = MinArgsExpected == 1 && MI->isVariadic();
}
return MacroArgs::create(MI, &ArgTokens[0], ArgTokens.size(),isVarargsElided);

View File

@ -14,3 +14,8 @@ X2()
X3(foo)
// RUN: clang-cc %s -E | grep 'AA BB'
// PR3880
#define X4(...) AA , ## __VA_ARGS__ BB
X4()