]> granicus.if.org Git - clang/commitdiff
[CodeGen][ObjC] Avoid asserting on block pointer types in
authorAlex Lorenz <arphaman@gmail.com>
Wed, 1 Feb 2017 17:37:28 +0000 (17:37 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Wed, 1 Feb 2017 17:37:28 +0000 (17:37 +0000)
isPointerZeroInitializable

rdar://30111891

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@293787 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenTypes.cpp
test/CodeGenObjC/block-ptr-type-crash.m [new file with mode: 0644]

index d2baeb4ea1f301aaa570b27323e8347d6a8ac4aa..c9e49a6af6f9a2997bd1e72573b9162fd325e00f 100644 (file)
@@ -738,7 +738,7 @@ CodeGenTypes::getCGRecordLayout(const RecordDecl *RD) {
 }
 
 bool CodeGenTypes::isPointerZeroInitializable(QualType T) {
-  assert (T->isAnyPointerType() && "Invalid type");
+  assert((T->isAnyPointerType() || T->isBlockPointerType()) && "Invalid type");
   return isZeroInitializable(T);
 }
 
diff --git a/test/CodeGenObjC/block-ptr-type-crash.m b/test/CodeGenObjC/block-ptr-type-crash.m
new file mode 100644 (file)
index 0000000..385d645
--- /dev/null
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -Wno-objc-root-class -fblocks -o /dev/null -triple x86_64-- -emit-llvm %s
+// REQUIRES: asserts
+// Verify there is no assertion.
+
+// rdar://30111891
+
+typedef unsigned long long uint64_t;
+typedef enum AnEnum : uint64_t AnEnum;
+enum AnEnum: uint64_t {
+    AnEnumA
+};
+
+typedef void (^BlockType)();
+@interface MyClass
+@end
+@implementation MyClass
+- (void)_doStuff {
+  struct {
+    int identifier;
+    AnEnum type;
+    BlockType handler;
+  } var = {
+    "hello",
+    AnEnumA,
+    ((void *)0)
+  };
+}
+@end