[cfe-commits] r111701 - in /cfe/trunk: lib/Lex/TokenLexer.cpp test/Preprocessor/macro_fn_comma_swallow.c
Chris Lattner
sabre at nondot.org
Fri Aug 20 17:27:00 PDT 2010
Author: lattner
Date: Fri Aug 20 19:27:00 2010
New Revision: 111701
URL: http://llvm.org/viewvc/llvm-project?rev=111701&view=rev
Log:
fix PR7943, a corner case with the GNU __VA_ARGS__ comma
swallowing extension.
Modified:
cfe/trunk/lib/Lex/TokenLexer.cpp
cfe/trunk/test/Preprocessor/macro_fn_comma_swallow.c
Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=111701&r1=111700&r2=111701&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Fri Aug 20 19:27:00 2010
@@ -268,6 +268,13 @@
// 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;
}
Modified: cfe/trunk/test/Preprocessor/macro_fn_comma_swallow.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_fn_comma_swallow.c?rev=111701&r1=111700&r2=111701&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/macro_fn_comma_swallow.c (original)
+++ cfe/trunk/test/Preprocessor/macro_fn_comma_swallow.c Fri Aug 20 19:27:00 2010
@@ -19,3 +19,8 @@
// 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)
More information about the cfe-commits
mailing list