rsmith added a comment. Thanks! Some simplifications are possible here, but otherwise this looks good.
================ Comment at: clang/lib/Sema/SemaExpr.cpp:14946 + // as invalid as well. + if (const CXXRecordDecl *RD = FieldType->getAsCXXRecordDecl()) { + if (RD->isInvalidDecl()) { ---------------- jgorbe wrote: > rsmith wrote: > > You'll need to use `FieldType->getBaseElementTypeUnsafe()` or similar here > > to handle the case where the field type is an array whose element type is a > > class. (That can happen in a lambda if you capture a local array variable > > by value.) > Done, I ended up using Context.getBaseElementType because the call to > RequireCompleteType below required a QualType. Hah, OK, now you've switched to using `RequireCompleteType` this has become redundant again (it'll walk to the base element type for you). =) ================ Comment at: clang/lib/Sema/SemaExpr.cpp:14952-14958 + NamedDecl *Def; + EltTy->isIncompleteType(&Def); + if (Def && Def->isInvalidDecl()) { + Lambda->setInvalidDecl(); + Field->setInvalidDecl(); + } + } ---------------- I believe the `else` case here is redundant: if `RequireCompleteType` returns `false`, the type is complete and there's nothing more you need to do. ================ Comment at: clang/test/SemaCXX/lambda-invalid-capture.cpp:8-12 +void h() { + g child; + auto q = [child]{}; + const int n = sizeof(q); +} ---------------- Can you also add a test for the "capturing an array of incomplete type" case please? https://reviews.llvm.org/D54550 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits