Clang Project

clang_source_code/test/SemaObjCXX/vararg-non-pod.mm
1// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-error=non-pod-varargs
2// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-error=non-pod-varargs -std=c++98
3// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-error=non-pod-varargs -std=c++11
4
5#if __cplusplus > 199711L
6// expected-no-diagnostics
7#endif
8
9extern char version[];
10
11@protocol P;
12
13class C {
14public:
15  C(int);
16};
17
18@interface D 
19- (void)g:(int)a, ...;
20@end
21
22void t1(D *d)
23{
24  C c(10);
25
26  [d g:10, c]; 
27#if __cplusplus <= 199711L // C++03 or earlier modes
28  // expected-warning@-2{{cannot pass object of non-POD type 'C' through variadic method; call will abort at runtime}}
29#endif
30  [d g:10, version];
31}
32
33void t2(D *d, id p)
34{
35  [d g:10, p];
36}
37
38void t3(D *d, id<P> p)
39{
40  [d g:10, p];
41}
42