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