This revision was automatically updated to reflect the committed changes. Closed by commit rC337766: [Sema] Fix crash on BlockExprs in a default member initializers (authored by epilk, committed by ).
Changed prior to commit: https://reviews.llvm.org/D49688?vs=156848&id=156906#toc Repository: rC Clang https://reviews.llvm.org/D49688 Files: lib/Sema/SemaTemplateInstantiate.cpp test/SemaCXX/instantiate-blocks.cpp Index: lib/Sema/SemaTemplateInstantiate.cpp =================================================================== --- lib/Sema/SemaTemplateInstantiate.cpp +++ lib/Sema/SemaTemplateInstantiate.cpp @@ -2083,6 +2083,11 @@ if (Member->getDeclContext() != Pattern) continue; + // BlockDecls can appear in a default-member-initializer. They must be the + // child of a BlockExpr, so we only know how to instantiate them from there. + if (isa<BlockDecl>(Member)) + continue; + if (Member->isInvalidDecl()) { Instantiation->setInvalidDecl(); continue; Index: test/SemaCXX/instantiate-blocks.cpp =================================================================== --- test/SemaCXX/instantiate-blocks.cpp +++ test/SemaCXX/instantiate-blocks.cpp @@ -30,3 +30,12 @@ noret((float)0.0, double(0.0)); // expected-note {{in instantiation of function template specialization 'noret<float, double>' requested here}} } +namespace rdar41200624 { +template <class T> +struct S { + int (^p)() = ^{ return 0; }; + T (^t)() = ^{ return T{}; }; + T s = ^{ return T{}; }(); +}; +S<int> x; +}
Index: lib/Sema/SemaTemplateInstantiate.cpp =================================================================== --- lib/Sema/SemaTemplateInstantiate.cpp +++ lib/Sema/SemaTemplateInstantiate.cpp @@ -2083,6 +2083,11 @@ if (Member->getDeclContext() != Pattern) continue; + // BlockDecls can appear in a default-member-initializer. They must be the + // child of a BlockExpr, so we only know how to instantiate them from there. + if (isa<BlockDecl>(Member)) + continue; + if (Member->isInvalidDecl()) { Instantiation->setInvalidDecl(); continue; Index: test/SemaCXX/instantiate-blocks.cpp =================================================================== --- test/SemaCXX/instantiate-blocks.cpp +++ test/SemaCXX/instantiate-blocks.cpp @@ -30,3 +30,12 @@ noret((float)0.0, double(0.0)); // expected-note {{in instantiation of function template specialization 'noret<float, double>' requested here}} } +namespace rdar41200624 { +template <class T> +struct S { + int (^p)() = ^{ return 0; }; + T (^t)() = ^{ return T{}; }; + T s = ^{ return T{}; }(); +}; +S<int> x; +}
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits