/gcc/testsuite/g++.apple/omit-destructor-call-scope.C
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
- /* APPLE LOCAL file 5559195 */
- // { dg-do compile }
- // { dg-final { scan-assembler-not "(\tcall|\tbl)\[ \]*__ZN6ClassAD1Ev" } }
- // { dg-final { scan-assembler "(\tcall|\tbl)\[ \]*__ZN6ClassBD1Ev" } }
- // Verify that implicit calls to empty destructors are omitted and implicit
- // calls to non-empty destructors are not omitted when instances fall out of
- // scope.
- int n;
- class ClassA {
- public:
- // Empty destructor. Should not be called when ClassA instance falls out
- // of scope.
- ~ClassA() {}
- };
- class ClassB {
- public:
- // Non-empty destructor. Should be called when ClassB instance falls out
- // of scope.
- ~ClassB() {
- n = 0;
- }
- };
- int
- main() {
- n = 1;
- {
- ClassA a; // Destructor not called.
- ClassB b; // Destructor called.
- }
- return n;
- }