summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/cleanup-dtor.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/ext/cleanup-dtor.C')
-rw-r--r--gcc/testsuite/g++.dg/ext/cleanup-dtor.C28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/ext/cleanup-dtor.C b/gcc/testsuite/g++.dg/ext/cleanup-dtor.C
new file mode 100644
index 000000000..58da64670
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/cleanup-dtor.C
@@ -0,0 +1,28 @@
+// Check that destructors are run after cleanup functions.
+// { dg-do run }
+
+extern "C" void abort ();
+
+int i;
+
+struct S {
+ ~S() {
+ if (i != 1)
+ abort ();
+ i = 2;
+ }
+};
+
+void f(void *) {
+ if (i != 0)
+ abort ();
+ i = 1;
+}
+
+int main () {
+ {
+ S s __attribute__((cleanup (f)));
+ }
+ if (i != 2)
+ abort ();
+}