Chris Lattner | 7e1848d | 2009-12-11 01:52:50 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify -fblocks %s -Wnon-pod-varargs |
Anders Carlsson | 906fed0 | 2009-01-13 05:48:52 +0000 | [diff] [blame] | 2 | |
Anders Carlsson | dce5e2c | 2009-01-16 16:48:51 +0000 | [diff] [blame] | 3 | extern char version[]; |
| 4 | |
Anders Carlsson | 906fed0 | 2009-01-13 05:48:52 +0000 | [diff] [blame] | 5 | class C { |
| 6 | public: |
| 7 | C(int); |
| 8 | void g(int a, ...); |
| 9 | static void h(int a, ...); |
| 10 | }; |
| 11 | |
| 12 | void g(int a, ...); |
| 13 | |
| 14 | void 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}} |
Anders Carlsson | dce5e2c | 2009-01-16 16:48:51 +0000 | [diff] [blame] | 19 | g(10, version); |
Anders Carlsson | 906fed0 | 2009-01-13 05:48:52 +0000 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | void 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}} |
Anders Carlsson | dce5e2c | 2009-01-16 16:48:51 +0000 | [diff] [blame] | 27 | c.g(10, version); |
Anders Carlsson | 906fed0 | 2009-01-13 05:48:52 +0000 | [diff] [blame] | 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}} |
Anders Carlsson | dce5e2c | 2009-01-16 16:48:51 +0000 | [diff] [blame] | 30 | C::h(10, version); |
Anders Carlsson | 906fed0 | 2009-01-13 05:48:52 +0000 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | int (^block)(int, ...); |
| 34 | |
| 35 | void 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}} |
Anders Carlsson | dce5e2c | 2009-01-16 16:48:51 +0000 | [diff] [blame] | 40 | block(10, version); |
Anders Carlsson | 906fed0 | 2009-01-13 05:48:52 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | class D { |
| 44 | public: |
| 45 | void operator() (int a, ...); |
| 46 | }; |
| 47 | |
| 48 | void t4() |
| 49 | { |
| 50 | C c(10); |
| 51 | |
| 52 | D d; |
| 53 | |
Anders Carlsson | d74d414 | 2009-09-08 01:48:42 +0000 | [diff] [blame] | 54 | d(10, c); // expected-warning{{cannot pass object of non-POD type 'class C' through variadic method; call will abort at runtime}} |
Anders Carlsson | dce5e2c | 2009-01-16 16:48:51 +0000 | [diff] [blame] | 55 | d(10, version); |
Anders Carlsson | 906fed0 | 2009-01-13 05:48:52 +0000 | [diff] [blame] | 56 | } |
Anders Carlsson | d74d414 | 2009-09-08 01:48:42 +0000 | [diff] [blame] | 57 | |
| 58 | class E { |
| 59 | E(int, ...); |
| 60 | }; |
| 61 | |
| 62 | void 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}} |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 68 | } |