]> granicus.if.org Git - clang/commitdiff
Revert "PR42587: diagnose unexpanded uses of a pack parameter of a generic" due to...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 23 Aug 2019 02:33:46 +0000 (02:33 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 23 Aug 2019 02:33:46 +0000 (02:33 +0000)
This reverts commit r369722.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@369725 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaLambda.cpp
lib/Sema/SemaTemplateVariadic.cpp
test/SemaCXX/cxx1y-generic-lambdas-variadics.cpp

index 6938804e5f185c17320363a19db18fe5cda5ecea..e7c51a3e3d92fb580caa7b32790390afc684cdda 100644 (file)
@@ -928,12 +928,12 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
 
     // Check for unexpanded parameter packs in the method type.
     if (MethodTyInfo->getType()->containsUnexpandedParameterPack())
-      DiagnoseUnexpandedParameterPack(Intro.Range.getBegin(), MethodTyInfo,
-                                      UPPC_DeclarationType);
+      ContainsUnexpandedParameterPack = true;
   }
 
   CXXRecordDecl *Class = createLambdaClosureType(Intro.Range, MethodTyInfo,
                                                  KnownDependent, Intro.Default);
+
   CXXMethodDecl *Method =
       startLambdaDefinition(Class, Intro.Range, MethodTyInfo, EndLoc, Params,
                             ParamInfo.getDeclSpec().getConstexprSpecifier());
index b766e3c5686f74af5ef0b2040bb4f028a661e889..f90bff6e7acfd32d3278b15f7c052e5a19511f67 100644 (file)
@@ -313,17 +313,10 @@ 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() == LambdaDC)
+          if (VD && VD->getDeclContext() == LSI->CallOperator)
             LambdaParamPackReferences.push_back(Pack);
         }
       }
index 22afdc08d9a45fb570e47812cfe81477d63cf189..b8022d209122e74dda6bdef2030d6e16319c43f2 100644 (file)
@@ -122,11 +122,3 @@ namespace PR33082 {
     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}}
-}