summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateVariadic.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-08-23 01:41:48 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-08-23 01:41:48 +0000
commit148028f12f2c1ece09e75344d88d2f96aafb4d9a (patch)
treefe95a5ff633f5688ec8d6a93362426c9b64a3b4f /lib/Sema/SemaTemplateVariadic.cpp
parent272b5247eb1b7e7c3784b24a0dc9dc996527b0fc (diff)
downloadclang-148028f12f2c1ece09e75344d88d2f96aafb4d9a.tar.gz
PR42587: diagnose unexpanded uses of a pack parameter of a generic
lambda from within the lambda-declarator. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@369722 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateVariadic.cpp')
-rw-r--r--lib/Sema/SemaTemplateVariadic.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Sema/SemaTemplateVariadic.cpp b/lib/Sema/SemaTemplateVariadic.cpp
index f90bff6e7a..b766e3c568 100644
--- a/lib/Sema/SemaTemplateVariadic.cpp
+++ b/lib/Sema/SemaTemplateVariadic.cpp
@@ -313,10 +313,17 @@ Sema::DiagnoseUnexpandedParameterPacks(SourceLocation Loc,
if (auto *LSI = dyn_cast<sema::LambdaScopeInfo>(Func)) {
if (N == FunctionScopes.size()) {
+ const DeclContext *LambdaDC = LSI->CallOperator;
+ // While we're parsing the lambda-declarator, we don't have a call
+ // operator yet and the parameters instead get temporarily attached
+ // to the translation unit.
+ if (!LambdaDC)
+ LambdaDC = Context.getTranslationUnitDecl();
+
for (auto &Pack : Unexpanded) {
auto *VD = dyn_cast_or_null<VarDecl>(
Pack.first.dyn_cast<NamedDecl *>());
- if (VD && VD->getDeclContext() == LSI->CallOperator)
+ if (VD && VD->getDeclContext() == LambdaDC)
LambdaParamPackReferences.push_back(Pack);
}
}