]> granicus.if.org Git - clang/commitdiff
Merging r293787:
authorHans Wennborg <hans@hanshq.net>
Wed, 1 Feb 2017 18:45:31 +0000 (18:45 +0000)
committerHans Wennborg <hans@hanshq.net>
Wed, 1 Feb 2017 18:45:31 +0000 (18:45 +0000)
------------------------------------------------------------------------
r293787 | arphaman | 2017-02-01 09:37:28 -0800 (Wed, 01 Feb 2017) | 5 lines

[CodeGen][ObjC] Avoid asserting on block pointer types in
isPointerZeroInitializable

rdar://30111891

------------------------------------------------------------------------

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

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

index b95b4fff57342d052131b45996a9e07d870a9c02..adb40c8c0d478a2e0269035e2ea21d29efceb0b5 100644 (file)
@@ -737,7 +737,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