p2.cpp 843 B

12345678910111213141516171819202122232425262728
  1. // RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify %s
  2. int *use_new(int N) {
  3. if (N == 1)
  4. return new int;
  5. return new int [N];
  6. }
  7. void use_delete(int* ip, int N) {
  8. if (N == 1)
  9. delete ip;
  10. else
  11. delete [] ip;
  12. }
  13. namespace std {
  14. class bad_alloc { };
  15. typedef __SIZE_TYPE__ size_t;
  16. }
  17. void* operator new(std::size_t) throw(std::bad_alloc); // expected-note{{previous declaration}}
  18. void* operator new[](std::size_t) throw(std::bad_alloc);
  19. void operator delete(void*) throw(); // expected-note{{previous declaration}}
  20. void operator delete[](void*) throw();
  21. void* operator new(std::size_t); // expected-warning{{'operator new' is missing exception specification 'throw(std::bad_alloc)'}}
  22. void operator delete(void*); // expected-warning{{'operator delete' is missing exception specification 'throw()'}}