summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiate.cpp5
-rw-r--r--clang/test/SemaCXX/instantiate-blocks.cpp9
2 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 5a4a6bd033c..3cf584344c1 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2083,6 +2083,11 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation,
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;
diff --git a/clang/test/SemaCXX/instantiate-blocks.cpp b/clang/test/SemaCXX/instantiate-blocks.cpp
index bb0f8d881d3..dbcef500b57 100644
--- a/clang/test/SemaCXX/instantiate-blocks.cpp
+++ b/clang/test/SemaCXX/instantiate-blocks.cpp
@@ -30,3 +30,12 @@ int main(void)
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;
+}
OpenPOWER on IntegriCloud