1*e3ea001eSRichard Smith // RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify -std=c++98 %s 2*e3ea001eSRichard Smith // RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify -std=c++11 %s 38feeb496SJohn McCall // RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify %s 487f54060SDouglas Gregor int *use_new(int N) { 587f54060SDouglas Gregor if (N == 1) 687f54060SDouglas Gregor return new int; 787f54060SDouglas Gregor 887f54060SDouglas Gregor return new int [N]; 987f54060SDouglas Gregor } 1087f54060SDouglas Gregor 1187f54060SDouglas Gregor void use_delete(int* ip, int N) { 1287f54060SDouglas Gregor if (N == 1) 1387f54060SDouglas Gregor delete ip; 1487f54060SDouglas Gregor else 1587f54060SDouglas Gregor delete [] ip; 1687f54060SDouglas Gregor } 1787f54060SDouglas Gregor 1887f54060SDouglas Gregor namespace std { 1987f54060SDouglas Gregor class bad_alloc { }; 2087f54060SDouglas Gregor 2187f54060SDouglas Gregor typedef __SIZE_TYPE__ size_t; 2287f54060SDouglas Gregor } 2387f54060SDouglas Gregor 24*e3ea001eSRichard Smith void* operator new(std::size_t) throw(std::bad_alloc); 25*e3ea001eSRichard Smith #if __cplusplus < 201103L 26*e3ea001eSRichard Smith // expected-note@-2 {{previous declaration}} 27*e3ea001eSRichard Smith #endif 2887f54060SDouglas Gregor void* operator new[](std::size_t) throw(std::bad_alloc); 29d6bc5e6bSDouglas Gregor void operator delete(void*) throw(); // expected-note{{previous declaration}} 3087f54060SDouglas Gregor void operator delete[](void*) throw(); 31d6bc5e6bSDouglas Gregor 32*e3ea001eSRichard Smith void* operator new(std::size_t); 33*e3ea001eSRichard Smith #if __cplusplus < 201103L 34*e3ea001eSRichard Smith // expected-warning@-2 {{'operator new' is missing exception specification 'throw(std::bad_alloc)'}} 35*e3ea001eSRichard Smith #endif 36*e3ea001eSRichard Smith void operator delete(void*); 37*e3ea001eSRichard Smith #if __cplusplus < 201103L 38*e3ea001eSRichard Smith // expected-warning@-2 {{'operator delete' is missing exception specification 'throw()'}} 39*e3ea001eSRichard Smith #else 40*e3ea001eSRichard Smith // expected-warning@-4 {{previously declared with an explicit exception specification redeclared with an implicit}} 41*e3ea001eSRichard Smith #endif 42