comparison clang/test/CodeGen/blocks-1.c @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 1d019706d866
children
comparison
equal deleted inserted replaced
232:70dce7da266c 236:c4bab56944e8
16 // RUN: grep "i32 135)" %t | count 2 16 // RUN: grep "i32 135)" %t | count 2
17 // RUN: grep "_Block_object_assign" %t | count 5 17 // RUN: grep "_Block_object_assign" %t | count 5
18 18
19 int printf(const char *, ...); 19 int printf(const char *, ...);
20 20
21 void test1() { 21 void test1(void) {
22 __block int a; 22 __block int a;
23 int b=2; 23 int b=2;
24 a=1; 24 a=1;
25 printf("a is %d, b is %d\n", a, b); 25 printf("a is %d, b is %d\n", a, b);
26 ^{ a = 10; printf("a is %d, b is %d\n", a, b); }(); // needs copy/dispose 26 ^{ a = 10; printf("a is %d, b is %d\n", a, b); }(); // needs copy/dispose
27 printf("a is %d, b is %d\n", a, b); 27 printf("a is %d, b is %d\n", a, b);
28 a = 1; 28 a = 1;
29 printf("a is %d, b is %d\n", a, b); 29 printf("a is %d, b is %d\n", a, b);
30 } 30 }
31 31
32 void test2() { 32 void test2(void) {
33 __block int a; 33 __block int a;
34 a=1; 34 a=1;
35 printf("a is %d\n", a); 35 printf("a is %d\n", a);
36 ^{ // needs copy/dispose 36 ^{ // needs copy/dispose
37 ^{ // needs copy/dispose 37 ^{ // needs copy/dispose
41 printf("a is %d\n", a); 41 printf("a is %d\n", a);
42 a = 1; 42 a = 1;
43 printf("a is %d\n", a); 43 printf("a is %d\n", a);
44 } 44 }
45 45
46 void test3() { 46 void test3(void) {
47 __block int k; 47 __block int k;
48 __block int (^j)(int); 48 __block int (^j)(int);
49 ^{j=0; k=0;}(); // needs copy/dispose 49 ^{j=0; k=0;}(); // needs copy/dispose
50 } 50 }
51 51
52 int test4() { 52 int test4(void) {
53 extern int g; 53 extern int g;
54 static int i = 1; 54 static int i = 1;
55 ^(int j){ i = j; g = 0; }(0); // does not need copy/dispose 55 ^(int j){ i = j; g = 0; }(0); // does not need copy/dispose
56 return i + g; 56 return i + g;
57 } 57 }
58 58
59 int g; 59 int g;
60 60
61 void test5() { 61 void test5(void) {
62 __block struct { int i; } i; 62 __block struct { int i; } i;
63 ^{ (void)i; }(); // needs copy/dispose 63 ^{ (void)i; }(); // needs copy/dispose
64 } 64 }
65 65
66 void test6() { 66 void test6(void) {
67 __block int i; 67 __block int i;
68 ^{ i=1; }(); // needs copy/dispose 68 ^{ i=1; }(); // needs copy/dispose
69 ^{}(); // does not need copy/dispose 69 ^{}(); // does not need copy/dispose
70 } 70 }
71 71
72 void test7() { 72 void test7(void) {
73 ^{ // does not need copy/dispose 73 ^{ // does not need copy/dispose
74 __block int i; 74 __block int i;
75 ^{ i = 1; }(); // needs copy/dispose 75 ^{ i = 1; }(); // needs copy/dispose
76 }(); 76 }();
77 } 77 }
78 78
79 int main() { 79 int main(void) {
80 int rv = 0; 80 int rv = 0;
81 test1(); 81 test1();
82 test2(); 82 test2();
83 test3(); 83 test3();
84 rv += test4(); 84 rv += test4();