r222476 - Fix crash-on-valid if a lambda-expression appears lexically directly within a

Richard Smith richard-llvm at metafoo.co.uk
Thu Nov 20 14:56:34 PST 2014


Author: rsmith
Date: Thu Nov 20 16:56:34 2014
New Revision: 222476

URL: http://llvm.org/viewvc/llvm-project?rev=222476&view=rev
Log:
Fix crash-on-valid if a lambda-expression appears lexically directly within a
local class inside a template.

Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
    cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=222476&r1=222475&r2=222476&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Thu Nov 20 16:56:34 2014
@@ -2555,7 +2555,10 @@ Sema::InstantiateClassMembers(SourceLoca
       // 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();

Modified: cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp?rev=222476&r1=222475&r2=222476&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp Thu Nov 20 16:56:34 2014
@@ -918,3 +918,10 @@ int run2 = x2.fooG3();
 
 
 } //end ns inclass_lambdas_within_nested_classes
+
+namespace lambda_in_default_mem_init {
+  template<typename T> void f() {
+    struct S { int n = []{ return 0; }(); };
+  }
+  template void f<int>();
+}





More information about the cfe-commits mailing list