diff options
author | Chris Lattner <sabre@nondot.org> | 2010-08-21 00:27:00 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-08-21 00:27:00 +0000 |
commit | 496af57256566c0db39b6a538bf7e4c6634afb2a (patch) | |
tree | 1fc2fde590685a05c55522384b4d7e34f82a7e68 /lib/Lex/TokenLexer.cpp | |
parent | 648d200efaad82e5289887d80d5082aab563fcc9 (diff) |
fix PR7943, a corner case with the GNU __VA_ARGS__ comma
swallowing extension.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111701 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/TokenLexer.cpp')
-rw-r--r-- | lib/Lex/TokenLexer.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index 49dc016590..94719b0baa 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/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; } |