| 1 | // RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify -std=c++98 %s |
| 2 | // RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify -std=c++11 %s |
| 3 | // RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify %s |
| 4 | int *use_new(int N) { |
| 5 | if (N == 1) |
| 6 | return new int; |
| 7 | |
| 8 | return new int [N]; |
| 9 | } |
| 10 | |
| 11 | void use_delete(int* ip, int N) { |
| 12 | if (N == 1) |
| 13 | delete ip; |
| 14 | else |
| 15 | delete [] ip; |
| 16 | } |
| 17 | |
| 18 | namespace std { |
| 19 | class bad_alloc { }; |
| 20 | |
| 21 | typedef __SIZE_TYPE__ size_t; |
| 22 | } |
| 23 | |
| 24 | void* operator new(std::size_t) throw(std::bad_alloc); |
| 25 | #if __cplusplus < 201103L |
| 26 | // expected-note@-2 {{previous declaration}} |
| 27 | #endif |
| 28 | void* operator new[](std::size_t) throw(std::bad_alloc); |
| 29 | void operator delete(void*) throw(); // expected-note{{previous declaration}} |
| 30 | void operator delete[](void*) throw(); |
| 31 | |
| 32 | void* operator new(std::size_t); |
| 33 | #if __cplusplus < 201103L |
| 34 | // expected-warning@-2 {{'operator new' is missing exception specification 'throw(std::bad_alloc)'}} |
| 35 | #endif |
| 36 | void operator delete(void*); |
| 37 | #if __cplusplus < 201103L |
| 38 | // expected-warning@-2 {{'operator delete' is missing exception specification 'throw()'}} |
| 39 | #else |
| 40 | // expected-warning@-4 {{previously declared with an explicit exception specification redeclared with an implicit}} |
| 41 | #endif |
| 42 | |