1// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
2// RUN: %clang_cc1 -DUSE -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
3
4// Maybe force the implicit declaration of 'operator delete' and 'operator
5// delete[]'. This should make no difference to anything!
6#ifdef USE
7void f(int *p) {
8  delete p;
9  delete [] p;
10}
11#endif
12
13// Deallocation functions are implicitly noexcept.
14// Thus, explicit specs aren't allowed to conflict.
15
16void operator delete(void*); // expected-warning {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}}
17void operator delete[](void*); // expected-warning {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}}
18
19static_assert(noexcept(operator delete(0)), "");
20static_assert(noexcept(operator delete[](0)), "");
21
22// Same goes for explicit declarations.
23void operator delete(void*, float);
24void operator delete[](void*, float);
25
26static_assert(noexcept(operator delete(0, 0.f)), "");
27static_assert(noexcept(operator delete[](0, 0.f)), "");
28
29// But explicit specs stay.
30void operator delete(void*, double) throw(int); // expected-note {{previous}}
31static_assert(!noexcept(operator delete(0, 0.)), "");
32void operator delete(void*, double) noexcept; // expected-error {{does not match}}
33