summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-08-11 23:30:23 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-08-11 23:30:23 +0000
commit36ee9fb219579e8bcac3032a042b3bddd98b3938 (patch)
tree335b274df5e87700dee249b936bfaa6e644dc351 /clang/lib/Sema
parent76502d84179e52d6ab1c657b4baf0e92ee27f912 (diff)
downloadbcm5719-llvm-36ee9fb219579e8bcac3032a042b3bddd98b3938.tar.gz
bcm5719-llvm-36ee9fb219579e8bcac3032a042b3bddd98b3938.zip
Reject varargs '...' in function prototype if there are more parameters after
it. Diagnose with recovery if it appears after a function parameter that was obviously supposed to be a parameter pack. Otherwise, warn if it immediately follows a function parameter pack, because the user most likely didn't intend to write a parameter pack followed by a C-style varargs ellipsis. This warning can be syntactically disabled by using ", ..." instead of "...". llvm-svn: 215408
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaTemplateVariadic.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp
index 8e4ce0d9da6..6e317d573b3 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -197,6 +197,20 @@ namespace {
};
}
+/// \brief Determine whether it's possible for an unexpanded parameter pack to
+/// be valid in this location. This only happens when we're in a declaration
+/// that is nested within an expression that could be expanded, such as a
+/// lambda-expression within a function call.
+///
+/// This is conservatively correct, but may claim that some unexpanded packs are
+/// permitted when they are not.
+bool Sema::isUnexpandedParameterPackPermitted() {
+ for (auto *SI : FunctionScopes)
+ if (isa<sema::LambdaScopeInfo>(SI))
+ return true;
+ return false;
+}
+
/// \brief Diagnose all of the unexpanded parameter packs in the given
/// vector.
bool
OpenPOWER on IntegriCloud