vararg-non-pod.cpp revision d74d4149f759b8abec15fb8163a4206e8c7068c8
1// RUN: clang-cc -fsyntax-only -verify -fblocks %s 2 3extern char version[]; 4 5class C { 6public: 7 C(int); 8 void g(int a, ...); 9 static void h(int a, ...); 10}; 11 12void g(int a, ...); 13 14void t1() 15{ 16 C c(10); 17 18 g(10, c); // expected-warning{{cannot pass object of non-POD type 'class C' through variadic function; call will abort at runtime}} 19 g(10, version); 20} 21 22void t2() 23{ 24 C c(10); 25 26 c.g(10, c); // expected-warning{{cannot pass object of non-POD type 'class C' through variadic method; call will abort at runtime}} 27 c.g(10, version); 28 29 C::h(10, c); // expected-warning{{cannot pass object of non-POD type 'class C' through variadic function; call will abort at runtime}} 30 C::h(10, version); 31} 32 33int (^block)(int, ...); 34 35void t3() 36{ 37 C c(10); 38 39 block(10, c); // expected-warning{{cannot pass object of non-POD type 'class C' through variadic block; call will abort at runtime}} 40 block(10, version); 41} 42 43class D { 44public: 45 void operator() (int a, ...); 46}; 47 48void t4() 49{ 50 C c(10); 51 52 D d; 53 54 d(10, c); // expected-warning{{cannot pass object of non-POD type 'class C' through variadic method; call will abort at runtime}} 55 d(10, version); 56} 57 58class E { 59 E(int, ...); 60}; 61 62void t5() 63{ 64 C c(10); 65 66 E e(10, c); // expected-warning{{cannot pass object of non-POD type 'class C' through variadic constructor; call will abort at runtime}} 67 (void)E(10, c); // expected-warning{{cannot pass object of non-POD type 'class C' through variadic constructor; call will abort at runtime}} 68}