Update analyzer build.
[clang.git] / test / CodeGen / blocks-1.c
blob1eb13063c68dc4b05d807fb4541acd463b6d5e9b
1 // RUN: %clang_cc1 %s -emit-llvm -o %t -fblocks
2 // RUN: grep "_Block_object_dispose" %t | count 17
3 // RUN: grep "__copy_helper_block_" %t | count 16
4 // RUN: grep "__destroy_helper_block_" %t | count 16
5 // RUN: grep "__Block_byref_object_copy_" %t | count 2
6 // RUN: grep "__Block_byref_object_dispose_" %t | count 2
7 // RUN: grep "i32 135)" %t | count 2
8 // RUN: grep "_Block_object_assign" %t | count 10
10 int printf(const char *, ...);
12 void test1() {
13 __block int a;
14 int b=2;
15 a=1;
16 printf("a is %d, b is %d\n", a, b);
17 ^{ a = 10; printf("a is %d, b is %d\n", a, b); }();
18 printf("a is %d, b is %d\n", a, b);
19 a = 1;
20 printf("a is %d, b is %d\n", a, b);
23 void test2() {
24 __block int a;
25 a=1;
26 printf("a is %d\n", a);
29 a = 10;
30 }();
31 }();
32 printf("a is %d\n", a);
33 a = 1;
34 printf("a is %d\n", a);
37 void test3() {
38 __block int k;
39 __block int (^j)(int);
40 ^{j=0; k=0;}();
43 int test4() {
44 extern int g;
45 static int i = 1;
46 ^(int j){ i = j; g = 0; }(0);
47 return i + g;
50 int g;
52 void test5() {
53 __block struct { int i; } i;
54 ^{ (void)i; }();
57 void test6() {
58 __block int i;
59 ^{ i=1; }();
60 ^{}();
63 void test7() {
65 __block int i;
66 ^{ i = 1; }();
67 }();
70 int main() {
71 int rv = 0;
72 test1();
73 test2();
74 test3();
75 rv += test4();
76 test5();
77 return rv;