diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-08-11 23:30:23 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-08-11 23:30:23 +0000 |
| commit | 36ee9fb219579e8bcac3032a042b3bddd98b3938 (patch) | |
| tree | 335b274df5e87700dee249b936bfaa6e644dc351 /clang/lib/Sema | |
| parent | 76502d84179e52d6ab1c657b4baf0e92ee27f912 (diff) | |
| download | bcm5719-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.cpp | 14 |
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 |

