summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/eh
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2009-09-30 17:56:00 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2009-09-30 17:56:00 +0000
commitb05ef1979438fb1c60ea319902f60806a97b6920 (patch)
tree08cb5e3cc8221234543e6b7a9400a117331ddd81 /gcc/testsuite/g++.dg/eh
parente2b51c17e421970310b0f369fa0efe09e0fe859b (diff)
downloadgcc-b05ef1979438fb1c60ea319902f60806a97b6920.tar.gz
* g++.dg/eh/init-temp1.C: Improve test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152341 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/g++.dg/eh')
-rw-r--r--gcc/testsuite/g++.dg/eh/init-temp1.C26
1 files changed, 18 insertions, 8 deletions
diff --git a/gcc/testsuite/g++.dg/eh/init-temp1.C b/gcc/testsuite/g++.dg/eh/init-temp1.C
index 29eae6972d6..529014f497f 100644
--- a/gcc/testsuite/g++.dg/eh/init-temp1.C
+++ b/gcc/testsuite/g++.dg/eh/init-temp1.C
@@ -1,19 +1,24 @@
// PR c++/15764
+// { dg-do run }
extern "C" void abort ();
-int counter = 0;
int thrown;
-struct a {
- ~a () { if (thrown++ == 0) throw 42; }
+
+int as;
+struct a {
+ a () { ++as; }
+ ~a () { --as; if (thrown++ == 0) throw 42; }
};
int f (a const&) { return 1; }
int f (a const&, a const&) { return 1; }
-
+
+int bs;
+int as_sav;
struct b {
- b (...) { ++counter; }
- ~b () { --counter; }
+ b (...) { ++bs; }
+ ~b () { --bs; as_sav = as; }
};
bool p;
@@ -29,7 +34,12 @@ int main () {
g();
}
- catch (...) {}
+ catch (...) {}
+
+ // We throw when the first a is destroyed, which should destroy b before
+ // the other a.
+ if (as_sav != 1)
+ abort ();
thrown = 0;
try {
@@ -39,6 +49,6 @@ int main () {
}
catch (...) {}
- if (counter != 0)
+ if (bs != 0)
abort ();
}