brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 22046f5 Raw
88 lines · c
1// RUN: %clang_cc1 -triple thumbv7-apple-ios %s -emit-llvm -o %t -fblocks2// RUN: grep "_Block_object_dispose" %t | count 123// RUN: grep "__copy_helper_block_" %t | count 94// RUN: grep "__destroy_helper_block_" %t | count 95// RUN: grep "__Block_byref_object_copy_" %t | count 26// RUN: grep "__Block_byref_object_dispose_" %t | count 27// RUN: grep "i32 135)" %t | count 28// RUN: grep "_Block_object_assign" %t | count 59 10// RUN: %clang_cc1 -triple thumbv7-unknown-windows %s -emit-llvm -o %t -fblocks11// RUN: grep "_Block_object_dispose" %t | count 1212// RUN: grep "__copy_helper_block_" %t | count 1113// RUN: grep "__destroy_helper_block_" %t | count 1114// RUN: grep "__Block_byref_object_copy_" %t | count 215// RUN: grep "__Block_byref_object_dispose_" %t | count 216// RUN: grep "i32 135)" %t | count 217// RUN: grep "_Block_object_assign" %t | count 518 19int printf(const char *, ...);20 21void test1(void) {22  __block int a;23  int b=2;24  a=1;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/dispose27  printf("a is %d, b is %d\n", a, b);28  a = 1;29  printf("a is %d, b is %d\n", a, b);30}31 32void test2(void) {33  __block int a;34  a=1;35  printf("a is %d\n", a);36  ^{ // needs copy/dispose37    ^{ // needs copy/dispose38      a = 10;39    }();40  }();41  printf("a is %d\n", a);42  a = 1;43  printf("a is %d\n", a);44}45 46void test3(void) {47  __block int k;48  __block int (^j)(int);49  ^{j=0; k=0;}(); // needs copy/dispose50}51 52int test4(void) {53  extern int g;54  static int i = 1;55  ^(int j){ i = j; g = 0; }(0); // does not need copy/dispose56  return i + g;57}58 59int g;60 61void test5(void) {62  __block struct { int i; } i;63  ^{ (void)i; }(); // needs copy/dispose64}65 66void test6(void) {67  __block int i;68  ^{ i=1; }(); // needs copy/dispose69  ^{}(); // does not need copy/dispose70}71 72void test7(void) {73  ^{ // does not need copy/dispose74    __block int i;75    ^{ i = 1; }(); // needs copy/dispose76  }();77}78 79int main(void) {80  int rv = 0;81  test1();82  test2();83  test3();84  rv += test4();85  test5();86  return rv;87}88