// Check for unexpanded parameter packs in the method type.
if (MethodTyInfo->getType()->containsUnexpandedParameterPack())
- ContainsUnexpandedParameterPack = true;
+ DiagnoseUnexpandedParameterPack(Intro.Range.getBegin(), MethodTyInfo,
+ UPPC_DeclarationType);
}
CXXRecordDecl *Class = createLambdaClosureType(Intro.Range, MethodTyInfo,
KnownDependent, Intro.Default);
-
CXXMethodDecl *Method =
startLambdaDefinition(Class, Intro.Range, MethodTyInfo, EndLoc, Params,
ParamInfo.getDeclSpec().getConstexprSpecifier());
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);
}
}
b(Pack<int*, float*>(), 1, 2, 3); // expected-note {{instantiation of}}
}
}
+
+void pr42587() {
+ (void)[](auto... args) -> decltype(args) {}; // expected-error {{type contains unexpanded parameter pack}}
+ (void)[](auto... args, int = args) {}; // expected-error {{default argument contains unexpanded parameter pack}}
+ (void)[](auto... args, decltype(args)) {}; // expected-error {{type contains unexpanded parameter pack}}
+ (void)[](auto... args, decltype(args)...) {}; // (ok)
+ (void)[](auto... args, int = [=] { return args; }()) {}; // expected-error {{default argument contains unexpanded parameter pack}}
+}