]> granicus.if.org Git - clang/commitdiff
When emitting l-values for bool non-__block decl references, make a pointer
authorJohn McCall <rjmccall@apple.com>
Thu, 28 Oct 2010 21:37:57 +0000 (21:37 +0000)
committerJohn McCall <rjmccall@apple.com>
Thu, 28 Oct 2010 21:37:57 +0000 (21:37 +0000)
using the memory type;  fixes an assert.

Fixes rdar://problem/8605032

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

lib/CodeGen/CGBlocks.cpp
test/CodeGen/blocks.c

index ca78781ec65d23e7292e8e901792f06dd6630334..44e0833daf560cc32dd003c4593d9fc7d3ad4ca8 100644 (file)
@@ -611,7 +611,7 @@ llvm::Value *CodeGenFunction::GetAddrOfBlockDecl(const ValueDecl *VD,
     if (VD->getType()->isReferenceType())
       V = Builder.CreateLoad(V);
   } else {
-    const llvm::Type *Ty = CGM.getTypes().ConvertType(VD->getType());
+    const llvm::Type *Ty = CGM.getTypes().ConvertTypeForMem(VD->getType());
     Ty = llvm::PointerType::get(Ty, 0);
     V = Builder.CreateBitCast(V, Ty);
     if (VD->getType()->isReferenceType())
index 6888356a5a1d6e251eaaaf6f8e3770b66b692981..b7b6a2d505efffcbfa846fccc1ee375fffe3dbc0 100644 (file)
@@ -33,3 +33,10 @@ typedef double ftype(double);
 ftype ^test2 = ^ftype {
   return 0;
 };
+
+// rdar://problem/8605032
+void f3_helper(void (^)(void));
+void f3() {
+  _Bool b = 0;
+  f3_helper(^{ if (b) {} });
+}