Fix crash-on-valid if a lambda-expression appears lexically directly within a
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 20 Nov 2014 22:56:34 +0000 (22:56 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 20 Nov 2014 22:56:34 +0000 (22:56 +0000)
local class inside a template.

llvm-svn: 222476

clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/SemaCXX/cxx1y-generic-lambdas.cpp

index 891cf73..c05960b 100644 (file)
@@ -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();
index 8e07b80..f3aae21 100644 (file)
@@ -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>();
+}