sepavloff added inline comments. ================ Comment at: lib/AST/DeclBase.cpp:273 @@ +272,3 @@ + return true; + if (const CXXRecordDecl *ClassD = dyn_cast<CXXRecordDecl>(LDC)) + return ClassD->isLocalClass() && !ClassD->isLambda();; ---------------- rsmith wrote: > It's not necessary for this change, but to match its documentation this > function should handle other kinds of `TagDecl` too (enums, C structs). > Something like: > > do { > if (LDC->isFunctionOrMethod()) > return true; > if (!isa<TagDecl>(LDC)) > return false; > LDC = LDC->getLexicalParent(); > } while (LDC); > return false; > > ... maybe? The proposed code recognizes lambda as lexically contained within a function. As a result, the following test starts to fail (obtained from CXX\expr\expr.prim\expr.prim.lambda\default-arguments.cpp): ``` struct NoDefaultCtor { NoDefaultCtor(const NoDefaultCtor&); // expected-note{{candidate constructor}} ~NoDefaultCtor(); };
template<typename T> void defargs_in_template_unused(T t) { auto l1 = [](const T& value = T()) { }; l1(t); } template void defargs_in_template_unused(NoDefaultCtor); ``` because default value for lambda argument cannot be instantiated. It is not clear whether instantiation of the lambda default argument must always occur similar to DR1484. I couldn't find appropriate place in the standard. According to spirit it shouldn't as lambda is not a separate declaration but a part of instantiated content. If so 14.6.4.1p2 is more likely to be applied and the above test must pass. Maybe we need to rename `isLexicallyWithinFunctionOrMethod` to `shouldBeAlwaysInstantiated` or something like that to avoid misunderstanding? http://reviews.llvm.org/D11194 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits