1 // RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks 2 3 void I( void (^)(void)); 4 void (^noop)(void); 5 6 void nothing(); 7 int printf(const char*, ...); 8 9 typedef void (^T) (void); 10 11 void takeblock(T); 12 int takeintint(int (^C)(int)) { return C(4); } 13 14 T somefunction() { 15 if (^{ }) 16 nothing(); 17 18 noop = ^{}; 19 20 noop = ^{printf("\nClosure\n"); }; 21 22 I(^{ }); 23 24 return ^{printf("\nClosure\n"); }; 25 } 26 void test2() { 27 int x = 4; 28 29 takeblock(^{ printf("%d\n", x); }); 30 31 while (1) { 32 takeblock(^{ 33 break; // expected-error {{'break' statement not in loop or switch statement}} 34 continue; // expected-error {{'continue' statement not in loop statement}} 35 while(1) break; // ok 36 goto foo; // expected-error {{use of undeclared label 'foo'}} 37 a: goto a; // ok 38 }); 39 break; 40 } 41 42 foo: 43 takeblock(^{ x = 4; }); // expected-error {{variable is not assignable (missing __block type specifier)}} 44 __block y = 7; // expected-warning {{type specifier missing, defaults to 'int'}} 45 takeblock(^{ y = 8; }); 46 } 47 48 49 void (^test3())(void) { 50 return ^{}; 51 } 52 53 void test4() { 54 void (^noop)(void) = ^{}; 55 void (*noop2)() = 0; 56 } 57 58 void myfunc(int (^block)(int)) {} 59 60 void myfunc3(const int *x); 61 62 void test5() { 63 int a; 64 65 myfunc(^(int abcd) { 66 myfunc3(&a); 67 return 1; 68 }); 69 } 70 71 void *X; 72 73 void test_arguments() { 74 int y; 75 int (^c)(char); 76 (1 ? c : 0)('x'); 77 (1 ? 0 : c)('x'); 78 79 (1 ? c : c)('x'); 80 } 81 82 static int global_x = 10; 83 void (^global_block)(void) = ^{ printf("global x is %d\n", global_x); }; 84 85 typedef void (^void_block_t)(void); 86 87 static const void_block_t myBlock = ^{ }; 88 89 static const void_block_t myBlock2 = ^ void(void) { }; 90