summaryrefslogtreecommitdiffstats
path: root/clang/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-07-29 04:39:41 +0000
committerChris Lattner <sabre@nondot.org>2006-07-29 04:39:41 +0000
commit775d83211094907e33d6ba09d07dc2c9f9424eb2 (patch)
treed80dc56f5332a778cafc1c1253aa51fa00f414d0 /clang/Lex/Preprocessor.cpp
parentd480b9c0ed26c3f30dda96a10211cbfee24235b4 (diff)
downloadbcm5719-llvm-775d83211094907e33d6ba09d07dc2c9f9424eb2.tar.gz
bcm5719-llvm-775d83211094907e33d6ba09d07dc2c9f9424eb2.zip
Implement the GNU comma swallowing extension. This implements
test/Preprocessor/macro_fn_comma_swallow.c llvm-svn: 38780
Diffstat (limited to 'clang/Lex/Preprocessor.cpp')
-rw-r--r--clang/Lex/Preprocessor.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/Lex/Preprocessor.cpp b/clang/Lex/Preprocessor.cpp
index c2c63f4c8c5..b6c6bc3610d 100644
--- a/clang/Lex/Preprocessor.cpp
+++ b/clang/Lex/Preprocessor.cpp
@@ -785,6 +785,9 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(LexerToken &MacroName,
// the count.
MinArgsExpected += MI->isC99Varargs();
+ // See MacroArgs instance var for description of this.
+ bool isVarargsElided = false;
+
if (NumActuals < MinArgsExpected) {
// There are several cases where too few arguments is ok, handle them now.
if (NumActuals+1 == MinArgsExpected && MI->isVariadic()) {
@@ -792,6 +795,10 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(LexerToken &MacroName,
// #define A(x, ...)
// 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());
} else if (MI->getNumArgs() == 1) {
// #define A(x)
// A()
@@ -816,7 +823,7 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(LexerToken &MacroName,
ArgTokens.push_back(Tok);
}
- return MacroArgs::create(MI, &ArgTokens[0], ArgTokens.size());
+ return MacroArgs::create(MI, &ArgTokens[0], ArgTokens.size(),isVarargsElided);
}
/// ComputeDATE_TIME - Compute the current time, enter it into the specified
OpenPOWER on IntegriCloud