Index: gcc/gcc/testsuite/g++.dg/eh/init-temp1.C |
diff --git a/gcc/gcc/testsuite/g++.dg/eh/init-temp1.C b/gcc/gcc/testsuite/g++.dg/eh/init-temp1.C |
index 29eae6972d63629e17dd79fb76e220088df3a911..529014f497f2052ca5fc94ac035e28f3d5983463 100644 |
--- a/gcc/gcc/testsuite/g++.dg/eh/init-temp1.C |
+++ b/gcc/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 (); |
} |