PageRenderTime 36ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/test/SemaCXX/warn-exit-time-destructors.cpp

https://github.com/alex-v-odesk/clang
C++ | 45 lines | 36 code | 8 blank | 1 comment | 0 complexity | 45a2e3c74c4d67a333d909071c32675b MD5 | raw file
Possible License(s): JSON
  1. // RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wexit-time-destructors %s -verify
  2. namespace test1 {
  3. struct A { ~A(); };
  4. A a; // expected-warning {{declaration requires an exit-time destructor}}
  5. A b[10]; // expected-warning {{declaration requires an exit-time destructor}}
  6. A c[10][10]; // expected-warning {{declaration requires an exit-time destructor}}
  7. A &d = a;
  8. A &e = b[5];
  9. A &f = c[5][7];
  10. }
  11. namespace test2 {
  12. void f() {
  13. struct A { ~A() { } };
  14. static A a; // expected-warning {{declaration requires an exit-time destructor}}
  15. static A b[10]; // expected-warning {{declaration requires an exit-time destructor}}
  16. static A c[10][10]; // expected-warning {{declaration requires an exit-time destructor}}
  17. static A &d = a;
  18. static A &e = b[5];
  19. static A &f = c[5][7];
  20. }
  21. }
  22. namespace test3 {
  23. struct A { ~A() = default; };
  24. A a;
  25. struct B { ~B(); };
  26. struct C : B { ~C() = default; };
  27. C c; // expected-warning {{exit-time destructor}}
  28. class D {
  29. friend struct E;
  30. ~D() = default;
  31. };
  32. struct E : D {
  33. D d;
  34. ~E() = default;
  35. };
  36. E e;
  37. }