From 20a2b46ca20070b0ddf3040ba8e3e7da301cca5f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 21 Aug 2010 00:27:00 +0000 Subject: fix PR7943, a corner case with the GNU __VA_ARGS__ comma swallowing extension. llvm-svn: 111701 --- clang/lib/Lex/TokenLexer.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'clang/lib/Lex/TokenLexer.cpp') diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp index 49dc016590a..94719b0baa3 100644 --- a/clang/lib/Lex/TokenLexer.cpp +++ b/clang/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; } -- cgit v1.2.3