Simplified check, organized tests.
http://reviews.llvm.org/D11006
Files:
lib/Parse/ParseDeclCXX.cpp
test/SemaCXX/cxx1y-generic-lambdas.cpp
test/SemaCXX/lambda-expressions.cpp
Index: test/SemaCXX/lambda-expressions.cpp
===================================================================
--- test/SemaCXX/lambda-expressions.cpp
+++ test/SemaCXX/lambda-expressions.cpp
@@ -446,3 +446,33 @@
template<typename Fn> fun<Fn> wrap(Fn fn);
auto x = wrap([](){});
}
+
+namespace PR13987 {
+class Enclosing {
+ void Method(char c = []()->char {
+ int d = []()->int {
+ struct LocalClass {
+ int Method() { return 0; }
+ };
+ return 0;
+ }();
+ return d; }()
+ );
+};
+}
+
+namespace PR23860 {
+template <class> struct A {
+ void f(int x = []() {
+ struct B {
+ void g() {}
+ };
+ return 0;
+ }());
+};
+
+int main() {
+}
+
+A<int> a;
+}
Index: test/SemaCXX/cxx1y-generic-lambdas.cpp
===================================================================
--- test/SemaCXX/cxx1y-generic-lambdas.cpp
+++ test/SemaCXX/cxx1y-generic-lambdas.cpp
@@ -948,3 +948,41 @@
auto x = f(0)();
}
+
+namespace PR13987 {
+class Enclosing {
+ void Method(char c = []()->char {
+ int d = [](auto x)->int {
+ struct LocalClass {
+ int Method() { return 0; }
+ };
+ return 0;
+ }(0);
+ return d; }()
+ );
+};
+
+class Enclosing2 {
+ void Method(char c = [](auto x)->char {
+ int d = []()->int {
+ struct LocalClass {
+ int Method() { return 0; }
+ };
+ return 0;
+ }();
+ return d; }(0)
+ );
+};
+
+class Enclosing3 {
+ void Method(char c = [](auto x)->char {
+ int d = [](auto y)->int {
+ struct LocalClass {
+ int Method() { return 0; }
+ };
+ return 0;
+ }(0);
+ return d; }(0)
+ );
+};
+}
Index: lib/Parse/ParseDeclCXX.cpp
===================================================================
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -2815,16 +2815,10 @@
break;
}
- if ((S->getFlags() & Scope::FnScope)) {
- // If we're in a function or function template declared in the
- // body of a class, then this is a local class rather than a
- // nested class.
- const Scope *Parent = S->getParent();
- if (Parent->isTemplateParamScope())
- Parent = Parent->getParent();
- if (Parent->isClassScope())
- break;
- }
+ if ((S->getFlags() & Scope::FnScope))
+ // If we're in a function or function template then this is a local
+ // class rather than a nested class.
+ break;
}
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits