The awesome GNU "comma elision extension" works with both the standard
__VA_ARGS__ syntax as well as with the amazingly awesome GNU "named
variadic macro" extension. Allow it with the GNU syntax as well.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50843 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp
index 23dfbbc..fb9b613 100644
--- a/lib/Lex/PPMacroExpansion.cpp
+++ b/lib/Lex/PPMacroExpansion.cpp
@@ -370,9 +370,12 @@
// A("blah")
Diag(Tok, diag::ext_missing_varargs_arg);
- // Remember this occurred if this is a C99 macro invocation with at least
- // one actual argument.
- isVarargsElided = MI->isC99Varargs() && MI->getNumArgs() > 1;
+ // Remember this occurred if this is a macro invocation with at least
+ // one actual argument. This allows us to elide the comma when used for
+ // cases like:
+ // #define A(x, foo...) blah(a, ## foo)
+ // #define A(x, ...) blah(a, ## __VA_ARGS__)
+ isVarargsElided = MI->getNumArgs() > 1;
} else if (MI->getNumArgs() == 1) {
// #define A(x)
// A()