diff options
Diffstat (limited to 'clang/test/SemaCXX/new-delete.cpp')
-rw-r--r-- | clang/test/SemaCXX/new-delete.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/test/SemaCXX/new-delete.cpp b/clang/test/SemaCXX/new-delete.cpp index 1ff1b2ecb5b..0a1a3aed310 100644 --- a/clang/test/SemaCXX/new-delete.cpp +++ b/clang/test/SemaCXX/new-delete.cpp @@ -16,7 +16,7 @@ void good_news() pi = new int('c'); const int *pci = new const int(); S *ps = new S(1, 2, 3.4); - ps = new (pf) S(1, 2, 3.4); + ps = new (pf) (S)(1, 2, 3.4); S *(*paps)[2] = new S*[*pi][2]; ps = new (S[3])(1, 2, 3.4); typedef int ia4[4]; @@ -29,7 +29,7 @@ void bad_news(int *ip) (void)new; // expected-error {{missing type specifier}} (void)new 4; // expected-error {{missing type specifier}} (void)new () int; // expected-error {{expected expression}} - (void)new int[1.1]; // expected-error {{size of array has non-integer type}} + (void)new int[1.1]; // expected-error {{array size expression must have integral or enumerated type, not 'double'}} (void)new int[1][i]; // expected-error {{only the first dimension}} (void)new (int[1][i]); // expected-error {{only the first dimension}} (void)new int(*(S*)0); // expected-error {{incompatible type initializing}} @@ -38,6 +38,9 @@ void bad_news(int *ip) (void)new S(1, 1); // expected-error {{call to constructor of 'S' is ambiguous}} (void)new const int; // expected-error {{must provide an initializer}} (void)new float*(ip); // expected-error {{incompatible type initializing 'int *', expected 'float *'}} + // Undefined, but clang should reject it directly. + (void)new int[-1]; // expected-error {{array size is negative}} + (void)new int[*(S*)0]; // expected-error {{array size expression must have integral or enumerated type, not 'struct S'}} // Some lacking cases due to lack of sema support. } |