[cfe-commits] r159477 - in /cfe/trunk: lib/AST/ASTContext.cpp test/CodeGen/block-3.c

Fariborz Jahanian fjahanian at apple.com
Fri Jun 29 17:48:59 PDT 2012


Author: fjahanian
Date: Fri Jun 29 19:48:59 2012
New Revision: 159477

URL: http://llvm.org/viewvc/llvm-project?rev=159477&view=rev
Log:
blocks: fixes a crash when encoding block type
with argument type of size 0. // rdar://11777609
PR13229.

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/test/CodeGen/block-3.c

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=159477&r1=159476&r2=159477&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Jun 29 19:48:59 2012
@@ -4149,6 +4149,8 @@
        E = Decl->param_end(); PI != E; ++PI) {
     QualType PType = (*PI)->getType();
     CharUnits sz = getObjCEncodingTypeSize(PType);
+    if (sz.isZero())
+      continue;
     assert (sz.isPositive() && "BlockExpr - Incomplete param type");
     ParmOffset += sz;
   }

Modified: cfe/trunk/test/CodeGen/block-3.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/block-3.c?rev=159477&r1=159476&r2=159477&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/block-3.c (original)
+++ cfe/trunk/test/CodeGen/block-3.c Fri Jun 29 19:48:59 2012
@@ -6,3 +6,15 @@
                 __attribute__((__blocks__(byref))) int index = ({ int __a; int __b; __a < __b ? __b : __a; });
    };
 }
+
+// PR13229
+// rdar://11777609
+typedef struct {} Z;
+
+typedef int (^B)(Z);
+
+void testPR13229() {
+  Z z1;
+  B b1 = ^(Z z1) { return 1; };
+  b1(z1);
+}





More information about the cfe-commits mailing list