p15.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132
  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. // Maybe force the implicit declaration of 'operator delete' and 'operator
  4. // delete[]'. This should make no difference to anything!
  5. #ifdef USE
  6. void f(int *p) {
  7. delete p;
  8. delete [] p;
  9. }
  10. #endif
  11. // Deallocation functions are implicitly noexcept.
  12. // Thus, explicit specs aren't allowed to conflict.
  13. void operator delete(void*); // expected-warning {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}}
  14. void operator delete[](void*); // expected-warning {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}}
  15. static_assert(noexcept(operator delete(0)), "");
  16. static_assert(noexcept(operator delete[](0)), "");
  17. // Same goes for explicit declarations.
  18. void operator delete(void*, float);
  19. void operator delete[](void*, float);
  20. static_assert(noexcept(operator delete(0, 0.f)), "");
  21. static_assert(noexcept(operator delete[](0, 0.f)), "");
  22. // But explicit specs stay.
  23. void operator delete(void*, double) throw(int); // expected-note {{previous}}
  24. static_assert(!noexcept(operator delete(0, 0.)), "");
  25. void operator delete(void*, double) noexcept; // expected-error {{does not match}}