From: Richard Smith Date: Thu, 20 Nov 2014 22:56:34 +0000 (+0000) Subject: Fix crash-on-valid if a lambda-expression appears lexically directly within a X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=620d1a5260364c2a5c8140615dd03efeb374d6a9;p=clang Fix crash-on-valid if a lambda-expression appears lexically directly within a local class inside a template. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222476 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index 891cf734c3..c05960b571 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -2555,7 +2555,10 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation, // Always skip the injected-class-name, along with any // redeclarations of nested classes, since both would cause us // to try to instantiate the members of a class twice. - if (Record->isInjectedClassName() || Record->getPreviousDecl()) + // Skip closure types; they'll get instantiated when we instantiate + // the corresponding lambda-expression. + if (Record->isInjectedClassName() || Record->getPreviousDecl() || + Record->isLambda()) continue; MemberSpecializationInfo *MSInfo = Record->getMemberSpecializationInfo(); diff --git a/test/SemaCXX/cxx1y-generic-lambdas.cpp b/test/SemaCXX/cxx1y-generic-lambdas.cpp index 8e07b806b1..f3aae219a4 100644 --- a/test/SemaCXX/cxx1y-generic-lambdas.cpp +++ b/test/SemaCXX/cxx1y-generic-lambdas.cpp @@ -918,3 +918,10 @@ int run2 = x2.fooG3(); } //end ns inclass_lambdas_within_nested_classes + +namespace lambda_in_default_mem_init { + template void f() { + struct S { int n = []{ return 0; }(); }; + } + template void f(); +}