blob: c34f8d0b8f1d9d0a5402a878395c97911fdda062 [file] [log] [blame]
Chris Lattner7e1848d2009-12-11 01:52:50 +00001// RUN: clang-cc -fsyntax-only -verify -fblocks %s -Wnon-pod-varargs
Anders Carlsson906fed02009-01-13 05:48:52 +00002
Anders Carlssondce5e2c2009-01-16 16:48:51 +00003extern char version[];
4
Anders Carlsson906fed02009-01-13 05:48:52 +00005class 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}}
Anders Carlssondce5e2c2009-01-16 16:48:51 +000019 g(10, version);
Anders Carlsson906fed02009-01-13 05:48:52 +000020}
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}}
Anders Carlssondce5e2c2009-01-16 16:48:51 +000027 c.g(10, version);
Anders Carlsson906fed02009-01-13 05:48:52 +000028
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 Carlssondce5e2c2009-01-16 16:48:51 +000030 C::h(10, version);
Anders Carlsson906fed02009-01-13 05:48:52 +000031}
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}}
Anders Carlssondce5e2c2009-01-16 16:48:51 +000040 block(10, version);
Anders Carlsson906fed02009-01-13 05:48:52 +000041}
42
43class D {
44public:
45 void operator() (int a, ...);
46};
47
48void t4()
49{
50 C c(10);
51
52 D d;
53
Anders Carlssond74d4142009-09-08 01:48:42 +000054 d(10, c); // expected-warning{{cannot pass object of non-POD type 'class C' through variadic method; call will abort at runtime}}
Anders Carlssondce5e2c2009-01-16 16:48:51 +000055 d(10, version);
Anders Carlsson906fed02009-01-13 05:48:52 +000056}
Anders Carlssond74d4142009-09-08 01:48:42 +000057
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}}
Daniel Dunbar4fcfde42009-11-08 01:45:36 +000068}