1 // RUN: clang-cc -fsyntax-only -verify %s
5 struct S
// expected-note {{candidate}}
7 S(int, int, double); // expected-note {{candidate}}
8 S(double, int); // expected-note 2 {{candidate}}
9 S(float, int); // expected-note 2 {{candidate}}
11 struct T
; // expected-note{{forward declaration of 'struct T'}}
14 // A special new, to verify that the global version isn't used.
15 void* operator new(size_t, S
*); // expected-note {{candidate}}
21 void* operator new(size_t); // expected-note 2 {{candidate}}
22 void* operator new(size_t, int*); // expected-note 3 {{candidate}}
23 void* operator new(size_t, float*); // expected-note 3 {{candidate}}
24 void* operator new(size_t, S
); // expected-note 2 {{candidate}}
29 float *pf
= new (pi
) float();
32 const int *pci
= new const int();
33 S
*ps
= new S(1, 2, 3.4);
34 ps
= new (pf
) (S
)(1, 2, 3.4);
35 S
*(*paps
)[2] = new S
*[*pi
][2];
36 ps
= new (S
[3])(1, 2, 3.4);
38 ia4
*pai
= new (int[3][4]);
41 // FIXME: Inherited functions are not looked up currently.
44 pi
= new (S(1.0f
, 2)) int;
48 virtual ~abstract() = 0;
51 void bad_news(int *ip
)
54 (void)new; // expected-error {{missing type specifier}}
55 (void)new 4; // expected-error {{missing type specifier}}
56 (void)new () int; // expected-error {{expected expression}}
57 (void)new int[1.1]; // expected-error {{array size expression must have integral or enumerated type, not 'double'}}
58 (void)new int[1][i
]; // expected-error {{only the first dimension}}
59 (void)new (int[1][i
]); // expected-error {{only the first dimension}}
60 (void)new int(*(S
*)0); // expected-error {{incompatible type initializing}}
61 (void)new int(1, 2); // expected-error {{initializer of a builtin type can only take one argument}}
62 (void)new S(1); // expected-error {{no matching constructor}}
63 (void)new S(1, 1); // expected-error {{call to constructor of 'S' is ambiguous}}
64 (void)new const int; // expected-error {{must provide an initializer}}
65 (void)new float*(ip
); // expected-error {{incompatible type initializing 'int *', expected 'float *'}}
66 // Undefined, but clang should reject it directly.
67 (void)new int[-1]; // expected-error {{array size is negative}}
68 (void)new int[*(S
*)0]; // expected-error {{array size expression must have integral or enumerated type, not 'struct S'}}
69 (void)::S::new int; // expected-error {{expected unqualified-id}}
70 (void)new (0, 0) int; // expected-error {{no matching function for call to 'operator new'}}
71 (void)new (0L) int; // expected-error {{call to 'operator new' is ambiguous}}
72 // This must fail, because the member version shouldn't be found.
73 (void)::new ((S
*)0) U
; // expected-error {{no matching function for call to 'operator new'}}
74 // This must fail, because any member version hides all global versions.
75 (void)new U
; // expected-error {{no matching function for call to 'operator new'}}
76 (void)new (int[]); // expected-error {{array size must be specified in new expressions}}
77 (void)new int&; // expected-error {{cannot allocate reference type 'int &' with new}}
78 // Some lacking cases due to lack of sema support.
91 delete 0; // expected-error {{cannot delete expression of type 'int'}}
92 delete [0] (int*)0; // expected-error {{expected ']'}} \
93 // expected-note {{to match this '['}}
94 delete (void*)0; // expected-error {{cannot delete expression}}
95 delete (T
*)0; // expected-warning {{deleting pointer to incomplete type}}
96 ::S::delete (int*)0; // expected-error {{expected unqualified-id}}