[PATCH] D49688: [Sema] Fix a crash when a BlockExpr appears in a default-member-initializer of a class template

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 23 15:47:57 PDT 2018


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;
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49688.156906.patch
Type: text/x-patch
Size: 1121 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180723/9d6e8dd6/attachment.bin>


More information about the cfe-commits mailing list