fix PR7943, a corner case with the GNU __VA_ARGS__ comma

swallowing extension.

llvm-svn: 111701
This commit is contained in:
Chris Lattner 2010-08-21 00:27:00 +00:00
parent 7a3f3a0402
commit 20a2b46ca2
2 changed files with 12 additions and 0 deletions

View File

@ -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;
}

View File

@ -19,3 +19,8 @@ X3(foo)
// PR3880
#define X4(...) AA , ## __VA_ARGS__ BB
X4()
// RUN: %clang_cc1 %s -E | grep '5: 1'
// PR7943
#define X5(x,...) x##,##__VA_ARGS__
5: X5(1)