19ca5c425SRichard Smith // RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
2*c7fb225cSRichard Smith // RUN: %clang_cc1 -DUSE -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
3*c7fb225cSRichard Smith 
4*c7fb225cSRichard Smith // Maybe force the implicit declaration of 'operator delete' and 'operator
5*c7fb225cSRichard Smith // delete[]'. This should make no difference to anything!
6*c7fb225cSRichard Smith #ifdef USE
f(int * p)7*c7fb225cSRichard Smith void f(int *p) {
8*c7fb225cSRichard Smith   delete p;
9*c7fb225cSRichard Smith   delete [] p;
10*c7fb225cSRichard Smith }
11*c7fb225cSRichard Smith #endif
1237588097SSebastian Redl 
1337588097SSebastian Redl // Deallocation functions are implicitly noexcept.
1437588097SSebastian Redl // Thus, explicit specs aren't allowed to conflict.
1537588097SSebastian Redl 
16*c7fb225cSRichard Smith void operator delete(void*); // expected-warning {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}}
17*c7fb225cSRichard Smith void operator delete[](void*); // expected-warning {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}}
1866f3ac9dSRichard Smith 
1966f3ac9dSRichard Smith static_assert(noexcept(operator delete(0)), "");
2066f3ac9dSRichard Smith static_assert(noexcept(operator delete[](0)), "");
2137588097SSebastian Redl 
2237588097SSebastian Redl // Same goes for explicit declarations.
2337588097SSebastian Redl void operator delete(void*, float);
2437588097SSebastian Redl void operator delete[](void*, float);
2566f3ac9dSRichard Smith 
2666f3ac9dSRichard Smith static_assert(noexcept(operator delete(0, 0.f)), "");
2766f3ac9dSRichard Smith static_assert(noexcept(operator delete[](0, 0.f)), "");
2837588097SSebastian Redl 
2937588097SSebastian Redl // But explicit specs stay.
3037588097SSebastian Redl void operator delete(void*, double) throw(int); // expected-note {{previous}}
3166f3ac9dSRichard Smith static_assert(!noexcept(operator delete(0, 0.)), "");
3237588097SSebastian Redl void operator delete(void*, double) noexcept; // expected-error {{does not match}}
33