Home | History | Annotate | Download | only in except.spec
      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
      7 void 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 
     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}}
     18 
     19 static_assert(noexcept(operator delete(0)), "");
     20 static_assert(noexcept(operator delete[](0)), "");
     21 
     22 // Same goes for explicit declarations.
     23 void operator delete(void*, float);
     24 void operator delete[](void*, float);
     25 
     26 static_assert(noexcept(operator delete(0, 0.f)), "");
     27 static_assert(noexcept(operator delete[](0, 0.f)), "");
     28 
     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}}
     33