blob: 5dd5f94af83012ae9822efe482efaa9fd8727e5f [file] [log] [blame]
Akira Hatanaka7275da02018-02-28 07:15:55 +00001// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -fsyntax-only -verify %s
2
3typedef struct {
4 id a;
5} Strong;
6
7void callee_variadic(const char *, ...);
8
9void test_variadic(void) {
10 Strong t;
11 callee_variadic("s", t); // expected-error {{cannot pass non-trivial C object of type 'Strong' by value to variadic function}}
12}
13
14void test_jump0(int cond) {
15 switch (cond) {
16 case 0:
17 ;
18 Strong x; // expected-note {{jump bypasses initialization of variable of non-trivial C struct type}}
19 break;
20 case 1: // expected-error {{cannot jump from switch statement to this case label}}
21 x.a = 0;
22 break;
23 }
24}
25
26void test_jump1(void) {
27 static void *ips[] = { &&L0 };
28L0: // expected-note {{possible target of indirect goto}}
29 ;
30 Strong x; // expected-note {{jump exits scope of variable with non-trivial destructor}}
31 goto *ips; // expected-error {{cannot jump}}
32}
33
34typedef void (^BlockTy)(void);
35void func(BlockTy);
36void func2(Strong);
37
38void test_block_scope0(int cond) {
39 Strong x; // expected-note {{jump enters lifetime of block which captures a C struct that is non-trivial to destroy}}
40 switch (cond) {
41 case 0:
42 func(^{ func2(x); });
43 break;
44 default: // expected-error {{cannot jump from switch statement to this case label}}
45 break;
46 }
47}
48
49void test_block_scope1(void) {
50 static void *ips[] = { &&L0 };
51L0: // expected-note {{possible target of indirect goto}}
52 ;
53 Strong x; // expected-note {{jump exits scope of variable with non-trivial destructor}} expected-note {{jump exits lifetime of block which captures a C struct that is non-trivial to destroy}}
54 func(^{ func2(x); });
55 goto *ips; // expected-error {{cannot jump}}
56}