1// 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} 57 58void test_compound_literal0(int cond, id x) { 59 switch (cond) { 60 case 0: 61 (void)(Strong){ .a = x }; // expected-note {{jump enters lifetime of a compound literal that is non-trivial to destruct}} 62 break; 63 default: // expected-error {{cannot jump from switch statement to this case label}} 64 break; 65 } 66} 67 68void test_compound_literal1(id x) { 69 static void *ips[] = { &&L0 }; 70L0: // expected-note {{possible target of indirect goto}} 71 ; 72 (void)(Strong){ .a = x }; // expected-note {{jump exits lifetime of a compound literal that is non-trivial to destruct}} 73 goto *ips; // expected-error {{cannot jump}} 74} 75