xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenObjC/2009-01-26-WriteBarrier-2.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fblocks -emit-llvm %s -fobjc-gc -o - | FileCheck %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc// CHECK: objc_assign_strongCast
4*f4a2713aSLionel Sambuc// rdar://5541393
5*f4a2713aSLionel Sambuc
6*f4a2713aSLionel Sambuctypedef __SIZE_TYPE__ size_t;
7*f4a2713aSLionel Sambucvoid * malloc(size_t size);
8*f4a2713aSLionel Sambuc
9*f4a2713aSLionel Sambuctypedef struct {
10*f4a2713aSLionel Sambuc    void (^ivarBlock)(void);
11*f4a2713aSLionel Sambuc} StructWithBlock_t;
12*f4a2713aSLionel Sambuc
13*f4a2713aSLionel Sambucint main(int argc, char *argv[]) {
14*f4a2713aSLionel Sambuc   StructWithBlock_t *swbp = (StructWithBlock_t *)malloc(sizeof(StructWithBlock_t*));
15*f4a2713aSLionel Sambuc   __block   int i = 10;
16*f4a2713aSLionel Sambuc   // assigning a Block into an struct slot should elicit a write-barrier under GC
17*f4a2713aSLionel Sambuc   swbp->ivarBlock = ^ { ++i; };
18*f4a2713aSLionel Sambuc   return 0;
19*f4a2713aSLionel Sambuc}
20