PageRenderTime 27ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/gcc/testsuite/g++.apple/omit-destructor-call-scope.C

https://bitbucket.org/danchr/llvm-gcc
C | 36 lines | 20 code | 5 blank | 11 comment | 0 complexity | cda1bec14949049c8e527134eb322db2 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, LGPL-2.0, BSD-3-Clause, CC-BY-SA-3.0
  1. /* APPLE LOCAL file 5559195 */
  2. // { dg-do compile }
  3. // { dg-final { scan-assembler-not "(\tcall|\tbl)\[ \]*__ZN6ClassAD1Ev" } }
  4. // { dg-final { scan-assembler "(\tcall|\tbl)\[ \]*__ZN6ClassBD1Ev" } }
  5. // Verify that implicit calls to empty destructors are omitted and implicit
  6. // calls to non-empty destructors are not omitted when instances fall out of
  7. // scope.
  8. int n;
  9. class ClassA {
  10. public:
  11. // Empty destructor. Should not be called when ClassA instance falls out
  12. // of scope.
  13. ~ClassA() {}
  14. };
  15. class ClassB {
  16. public:
  17. // Non-empty destructor. Should be called when ClassB instance falls out
  18. // of scope.
  19. ~ClassB() {
  20. n = 0;
  21. }
  22. };
  23. int
  24. main() {
  25. n = 1;
  26. {
  27. ClassA a; // Destructor not called.
  28. ClassB b; // Destructor called.
  29. }
  30. return n;
  31. }