This revision was automatically updated to reflect the committed changes. Closed by commit rL242132: Classes inside lambdas are local not nested. (authored by sepavloff).
Changed prior to commit: http://reviews.llvm.org/D11006?vs=29246&id=29656#toc Repository: rL LLVM http://reviews.llvm.org/D11006 Files: cfe/trunk/lib/Parse/ParseDeclCXX.cpp cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp cfe/trunk/test/SemaCXX/lambda-expressions.cpp
Index: cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp =================================================================== --- cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp +++ cfe/trunk/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: cfe/trunk/test/SemaCXX/lambda-expressions.cpp =================================================================== --- cfe/trunk/test/SemaCXX/lambda-expressions.cpp +++ cfe/trunk/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: cfe/trunk/lib/Parse/ParseDeclCXX.cpp =================================================================== --- cfe/trunk/lib/Parse/ParseDeclCXX.cpp +++ cfe/trunk/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 cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits