1// RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
2
3void I( void (^)(void));
4void (^noop)(void);
5
6void nothing();
7int printf(const char*, ...);
8
9typedef void (^T) (void);
10
11void takeblock(T);
12int takeintint(int (^C)(int)) { return C(4); }
13
14T somefunction() {
15  if (^{ })
16    nothing();
17
18  noop = ^{};
19
20  noop = ^{printf("\nClosure\n"); };
21
22  I(^{ });
23
24  return ^{printf("\nClosure\n"); };
25}
26void 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
49void (^test3())(void) {
50  return ^{};
51}
52
53void test4() {
54  void (^noop)(void) = ^{};
55  void (*noop2)() = 0;
56}
57
58void myfunc(int (^block)(int)) {}
59
60void myfunc3(const int *x);
61
62void test5() {
63  int a;
64
65  myfunc(^(int abcd) {
66      myfunc3(&a);
67      return 1;
68    });
69}
70
71void *X;
72
73void 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
82static int global_x = 10;
83void (^global_block)(void) = ^{ printf("global x is %d\n", global_x); };
84
85typedef void (^void_block_t)(void);
86
87static const void_block_t myBlock = ^{ };
88
89static const void_block_t myBlock2 = ^ void(void) { };
90