vararg-non-pod.cpp revision dce5e2cabf07ff25eb4d9e1859c0a21c69f588d2
1// RUN: clang -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{{Line 48: cannot pass object of non-POD type 'class C' through variadic method; call will abort at runtime}}
55  d(10, version);
56}
57