init7.C: New test: retry initialization of static locals if first initialization...
authorAlexandre Oliva <oliva@dcc.unicamp.br>
Wed, 7 Oct 1998 20:41:38 +0000 (20:41 +0000)
committerAlexandre Oliva <oliva@gcc.gnu.org>
Wed, 7 Oct 1998 20:41:38 +0000 (20:41 +0000)
* g++.old-deja/g++.other/init7.C: New test: retry initialization
  of static locals if first initialization throws

From-SVN: r22901

gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.other/init7.C [new file with mode: 0644]

index f038a885afc6e03f796462b94b8cee86e28846e0..310ee0ed08ef730d9e59cd1447d767cb34bbcf14 100644 (file)
@@ -1,3 +1,8 @@
+1998-10-08  Alexandre Oliva  <oliva@dcc.unicamp.br>
+
+       * g++.old-deja/g++.other/init7.C: New test: retry initialization
+       of static locals if first initialization throws
+
 Wed Oct  7 12:00:20 1998  Jim Wilson  <wilson@cygnus.com>
 
        * gcc.c-torture/compile/981007-1.c: New test for irix6 -O0 core dump.
diff --git a/gcc/testsuite/g++.old-deja/g++.other/init7.C b/gcc/testsuite/g++.old-deja/g++.other/init7.C
new file mode 100644 (file)
index 0000000..9a3d5d0
--- /dev/null
@@ -0,0 +1,30 @@
+// simplified from testcase in Windows Developer Journal,
+// submitted by eyal.ben-david@aks.com
+
+// The initialization of a static local variable must be retried if a
+// previous try finished by throwing an exception [stmt.dcl]/4
+
+// execution test - XFAIL *-*-*
+
+struct foo {
+  foo() { throw true; }
+};
+
+void bar() {
+  static foo baz;
+}
+
+int main() {
+  try {
+    bar(); // must throw
+  }
+  catch (bool) {
+    try {
+      bar(); // must throw again!
+    }
+    catch (bool) {
+      return 0;
+    }
+  }
+  abort();
+}