Debian Codegraph @

clang/test/CodeGenObjC/2009-01-26-WriteBarrier-2.m

raw
1 // RUN: %clang_cc1 -fblocks -emit-llvm %s -fobjc-gc -o - | FileCheck %s
2
3 // CHECK: objc_assign_strongCast
4
5 typedef __SIZE_TYPE__ size_t;
6 void * malloc(size_t size);
7
8 typedef struct {
9 void (^ivarBlock)(void);
10 } StructWithBlock_t;
11
12 int main(int argc, char *argv[]) {
13 StructWithBlock_t *swbp = (StructWithBlock_t *)malloc(sizeof(StructWithBlock_t*));
14 __block int i = 10;
15 // assigning a Block into an struct slot should elicit a write-barrier under GC
16 swbp->ivarBlock = ^ { ++i; };
17 return 0;
18 }