[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Sema / block-literal.c
blobd1607cec098c51ac98544134d54333b834aa14e1
1 // RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
3 void I( void (^)(void));
4 void (^noop)(void);
6 void nothing(void);
7 int printf(const char*, ...);
9 typedef void (^T) (void);
11 void takeblock(T);
12 int takeintint(int (^C)(int)) { return C(4); }
14 T somefunction(void) {
15 if (^{ })
16 nothing();
18 noop = ^{};
20 noop = ^{printf("\nClosure\n"); };
22 I(^{ });
24 return ^{printf("\nClosure\n"); };
26 void test2(void) {
27 int x = 4;
29 takeblock(^{ printf("%d\n", x); });
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;
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; });
49 void (^test3(void))(void) {
50 return ^{};
53 void test4(void) {
54 void (^noop)(void) = ^{};
55 void (*noop2)(void) = 0;
58 void myfunc(int (^block)(int)) {}
60 void myfunc3(const int *x);
62 void test5(void) {
63 int a;
65 myfunc(^(int abcd) {
66 myfunc3(&a);
67 return 1;
68 });
71 void *X;
73 void test_arguments(void) {
74 int y;
75 int (^c)(char);
76 (1 ? c : 0)('x');
77 (1 ? 0 : c)('x');
79 (1 ? c : c)('x');
82 static int global_x = 10;
83 void (^global_block)(void) = ^{ printf("global x is %d\n", global_x); };
85 typedef void (^void_block_t)(void);
87 static const void_block_t myBlock = ^{ };
89 static const void_block_t myBlock2 = ^ void(void) { };