blob: 449fcee6489792046ff964b7edd6a15ff5333729 [file] [log] [blame]
Sebastian Redl4c5d3202008-11-21 19:14:01 +00001struct S // expected-note {{candidate}}
2{
3 S(int, int, double); // expected-note {{candidate}}
4 S(double, int); // expected-note {{candidate}} expected-note {{candidate}}
5 S(float, int); // expected-note {{candidate}} expected-note {{candidate}}
6};
7struct T;
8
9void good_news()
10{
11 int *pi = new int;
12 float *pf = new (pi) float();
13 pi = new int(1);
14 pi = new int('c');
15 const int *pci = new const int();
16 S *ps = new S(1, 2, 3.4);
17 ps = new (pf) S(1, 2, 3.4);
18 S *(*paps)[2] = new S*[*pi][2];
19 ps = new (S[3])(1, 2, 3.4);
20 typedef int ia4[4];
21 ia4 *pai = new (int[3][4]);
22}
23
24void bad_news()
25{
26 int i = 1;
27 (void)new; // expected-error {{missing type specifier}}
28 (void)new 4; // expected-error {{missing type specifier}}
29 (void)new () int; // expected-error {{expected expression}}
30 (void)new int[1.1]; // expected-error {{size of array has non-integer type}}
31 (void)new int[1][i]; // expected-error {{only the first dimension}}
32 (void)new (int[1][i]); // expected-error {{only the first dimension}}
33 (void)new int(*(S*)0); // expected-error {{incompatible type initializing}}
34 (void)new int(1, 2); // expected-error {{initializer of a builtin type can only take one argument}}
35 (void)new S(1); // expected-error {{no matching constructor}}
36 (void)new S(1, 1); // expected-error {{call to constructor of 'struct S' is ambiguous}}
37 (void)new const int; // expected-error {{must provide an initializer}}
38
39 // Some lacking cases due to lack of sema support.
40}
41
42void good_deletes()
43{
44 delete (int*)0;
45 delete [](int*)0;
46 delete (S*)0;
47}
48
49void bad_deletes()
50{
51 delete 0; // expected-error {{cannot delete expression of type 'int'}}
52 delete [0] (int*)0; // expected-error {{expected ']'}} \
53 // expected-error {{to match this '['}}
54 delete (void*)0; // expected-error {{cannot delete expression}}
55 delete (T*)0; // expected-warning {{deleting pointer to incomplete type}}
56}