[cfe-commits] r67706 - in /cfe/trunk: lib/Lex/PPMacroExpansion.cpp test/Preprocessor/macro_fn_comma_swallow.c
Chris Lattner
sabre at nondot.org
Wed Mar 25 14:08:24 PDT 2009
Author: lattner
Date: Wed Mar 25 16:08:24 2009
New Revision: 67706
URL: http://llvm.org/viewvc/llvm-project?rev=67706&view=rev
Log:
fix PR3880, fixing a comma swallowing bug handling macros that only take
.. arguments.
Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/Preprocessor/macro_fn_comma_swallow.c
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=67706&r1=67705&r2=67706&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed Mar 25 16:08:24 2009
@@ -403,6 +403,12 @@
Tok.setLocation(EndLoc);
Tok.setLength(0);
ArgTokens.push_back(Tok);
+ } else if (NumActuals == 1 && ArgTokens.size() == 1) {
+ // If there is exactly one argument, and that argument is just an EOF token,
+ // then we have an empty "()" argument empty list. This is fine, even if
+ // the macro expects one argument (the argument is just empty). However, if
+ // the macro expects "...", then we need to know that it was elided.
+ isVarargsElided = MinArgsExpected == 1 && MI->isVariadic();
}
return MacroArgs::create(MI, &ArgTokens[0], ArgTokens.size(),isVarargsElided);
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=67706&r1=67705&r2=67706&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/macro_fn_comma_swallow.c (original)
+++ cfe/trunk/test/Preprocessor/macro_fn_comma_swallow.c Wed Mar 25 16:08:24 2009
@@ -14,3 +14,8 @@
X3(foo)
+
+// RUN: clang-cc %s -E | grep 'AA BB'
+// PR3880
+#define X4(...) AA , ## __VA_ARGS__ BB
+X4()
More information about the cfe-commits
mailing list