[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CXX / except / except.spec / p15.cpp
blobacf4426a8eb56091e73c056416f08c5fd6527450
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
4 // Maybe force the implicit declaration of 'operator delete' and 'operator
5 // delete[]'. This should make no difference to anything!
6 #ifdef USE
7 void f(int *p) {
8 delete p;
9 delete [] p;
11 #endif
13 // Deallocation functions are implicitly noexcept.
14 // Thus, explicit specs aren't allowed to conflict.
16 void operator delete(void*); // expected-warning {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}}
17 void operator delete[](void*); // expected-warning {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}}
19 static_assert(noexcept(operator delete(0)), "");
20 static_assert(noexcept(operator delete[](0)), "");
22 // Same goes for explicit declarations.
23 void operator delete(void*, float);
24 void operator delete[](void*, float);
26 static_assert(noexcept(operator delete(0, 0.f)), "");
27 static_assert(noexcept(operator delete[](0, 0.f)), "");
29 // But explicit specs stay.
30 void operator delete(void*, double) throw(int); // expected-note {{previous}}
31 static_assert(!noexcept(operator delete(0, 0.)), "");
32 void operator delete(void*, double) noexcept; // expected-error {{does not match}}