aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@gcc.gnu.org>1997-12-03 15:29:19 -0500
committerJason Merrill <jason@gcc.gnu.org>1997-12-03 15:29:19 -0500
commitca6d8cae45369624280a6c821e4a0c0090f4a480 (patch)
treec9eca2d86d85ba641214caf1e3b0da8ffc1ef48b /gcc
parent9762d48da5d567c89e920a51149a2c9aef960150 (diff)
downloadgcc-ca6d8cae45369624280a6c821e4a0c0090f4a480.zip
gcc-ca6d8cae45369624280a6c821e4a0c0090f4a480.tar.gz
gcc-ca6d8cae45369624280a6c821e4a0c0090f4a480.tar.bz2
new
From-SVN: r16930
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/g++.old-deja/g++.eh/cleanup1.C34
-rw-r--r--gcc/testsuite/g++.old-deja/g++.eh/new1.C44
-rw-r--r--gcc/testsuite/g++.old-deja/g++.eh/new2.C44
-rw-r--r--gcc/testsuite/g++.old-deja/g++.eh/ptr1.C22
-rw-r--r--gcc/testsuite/g++.old-deja/g++.eh/rethrow4.C45
-rw-r--r--gcc/testsuite/g++.old-deja/g++.eh/rethrow5.C44
-rw-r--r--gcc/testsuite/g++.old-deja/g++.jason/destruct3.C5
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/enum2.C17
8 files changed, 253 insertions, 2 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/cleanup1.C b/gcc/testsuite/g++.old-deja/g++.eh/cleanup1.C
new file mode 100644
index 0000000..6faea26
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/cleanup1.C
@@ -0,0 +1,34 @@
+// Bug: obj gets destroyed twice because the fixups for the return are
+// inside its cleanup region.
+
+extern "C" int printf (const char *, ...);
+
+int d;
+
+struct myExc { };
+
+struct myExcRaiser {
+ ~myExcRaiser() { throw myExc(); }
+};
+
+struct stackObj {
+ ~stackObj() { ++d; printf ("stackObj::~stackObj()\n"); };
+};
+
+int test()
+{
+ myExcRaiser rais;
+ stackObj obj;
+ return 0;
+}
+
+int main()
+{
+ try {
+ test();
+ }
+ catch (myExc &) {
+ return d != 1;
+ }
+ return 1;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/new1.C b/gcc/testsuite/g++.old-deja/g++.eh/new1.C
new file mode 100644
index 0000000..3f7ebbc
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/new1.C
@@ -0,0 +1,44 @@
+// Test that a throw in foo destroys the A, but does not free the memory.
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <new.h>
+
+struct A {
+ A();
+ ~A();
+};
+
+struct B {
+ B (A);
+};
+
+void foo (B*);
+
+int newed, created;
+
+main ()
+{
+ try {
+ foo (new B (A ()));
+ } catch (...) { }
+
+ return !(newed && !created);
+}
+
+A::A() { created = 1; }
+A::~A() { created = 0; }
+B::B(A) { }
+void foo (B*) { throw 1; }
+
+void* operator new (size_t size) throw (std::bad_alloc)
+{
+ ++newed;
+ return (void *) malloc (size);
+}
+
+void operator delete (void *p) throw ()
+{
+ --newed;
+ free (p);
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/new2.C b/gcc/testsuite/g++.old-deja/g++.eh/new2.C
new file mode 100644
index 0000000..6699f94
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/new2.C
@@ -0,0 +1,44 @@
+// Test that a throw in B's constructor destroys the A and frees the memory.
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <new.h>
+
+struct A {
+ A();
+ ~A();
+};
+
+struct B {
+ B (A);
+};
+
+void foo (B*);
+
+int newed, created;
+
+main ()
+{
+ try {
+ foo (new B (A ()));
+ } catch (...) { }
+
+ return !(!newed && !created);
+}
+
+A::A() { created = 1; }
+A::~A() { created = 0; }
+B::B(A) { throw 1; }
+void foo (B*) { }
+
+void* operator new (size_t size) throw (std::bad_alloc)
+{
+ ++newed;
+ return (void *) malloc (size);
+}
+
+void operator delete (void *p) throw ()
+{
+ --newed;
+ free (p);
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/ptr1.C b/gcc/testsuite/g++.old-deja/g++.eh/ptr1.C
new file mode 100644
index 0000000..2249526
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/ptr1.C
@@ -0,0 +1,22 @@
+// Bug: catching pointers by reference doesn't work right.
+
+extern "C" int printf (const char *, ...);
+
+struct E {
+ int x;
+ E(int i) { x = i; };
+};
+
+int main()
+{
+ try {
+ E *p = new E(5);
+ throw p;
+ }
+
+ catch (E *&e) {
+ printf ("address of e is 0x%x\n", (long)e);
+ return !(long(e) != 5 && e->x == 5);
+ }
+ return 2;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/rethrow4.C b/gcc/testsuite/g++.old-deja/g++.eh/rethrow4.C
new file mode 100644
index 0000000..c5dcd23
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/rethrow4.C
@@ -0,0 +1,45 @@
+// Testcase for proper handling of rethrow.
+
+#include <stdio.h>
+
+int c, d;
+
+struct A
+{
+ int i;
+ A () { i = ++c; printf ("A() %d\n", i); }
+ A (const A&) { i = ++c; printf ("A(const A&) %d\n", i); }
+ ~A() { printf ("~A() %d\n", i); ++d; }
+};
+
+int
+main ()
+{
+ try
+ {
+ try
+ {
+ printf ("Throwing 1...\n");
+ throw A();
+ }
+ catch (A)
+ {
+ try
+ {
+ printf ("Throwing 2...\n");
+ throw;
+ }
+ catch (A)
+ {
+ printf ("Throwing 3...\n");
+ throw A();
+ }
+ }
+ }
+ catch (A)
+ {
+ printf ("Caught.\n");
+ }
+ printf ("c == %d, d == %d\n", c, d);
+ return c != d;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/rethrow5.C b/gcc/testsuite/g++.old-deja/g++.eh/rethrow5.C
new file mode 100644
index 0000000..f137d18
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/rethrow5.C
@@ -0,0 +1,44 @@
+// Testcase for proper handling of rethrow.
+
+#include <stdio.h>
+
+int c, d;
+
+struct A
+{
+ int i;
+ A () { i = ++c; printf ("A() %d\n", i); }
+ A (const A&) { i = ++c; printf ("A(const A&) %d\n", i); }
+ ~A() { printf ("~A() %d\n", i); ++d; }
+};
+
+int
+main ()
+{
+ try
+ {
+ try
+ {
+ printf ("Throwing 1...\n");
+ throw A();
+ }
+ catch (A)
+ {
+ try
+ {
+ printf ("Throwing 2...\n");
+ throw;
+ }
+ catch (A)
+ {
+ printf ("Falling out...\n");
+ }
+ }
+ }
+ catch (A)
+ {
+ printf ("Caught.\n");
+ }
+ printf ("c == %d, d == %d\n", c, d);
+ return c != d;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.jason/destruct3.C b/gcc/testsuite/g++.old-deja/g++.jason/destruct3.C
index 94ca834..d4bbf9a 100644
--- a/gcc/testsuite/g++.old-deja/g++.jason/destruct3.C
+++ b/gcc/testsuite/g++.old-deja/g++.jason/destruct3.C
@@ -1,3 +1,4 @@
+// Special g++ Options: -w
// PRMS Id: 4342 (second testcase)
// Bug: g++ still can't deal with ambiguous inheritance in destructor calls.
// Build don't link:
@@ -32,10 +33,10 @@ struct ccScreenObj : public ccScreenObjRep
{};
struct ccVSTool : public ccImpExp, public ccUnwind
-{}; // gets bogus error - XFAIL *-*-*
+{};
struct ccSCCP : public ccVSTool
-{}; // gets bogus error - XFAIL *-*-*
+{};
void foo ()
{
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum2.C b/gcc/testsuite/g++.old-deja/g++.pt/enum2.C
new file mode 100644
index 0000000..5a2d7f3
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.pt/enum2.C
@@ -0,0 +1,17 @@
+// Build don't link:
+
+struct U {
+ static int STATIC;
+};
+
+template <int* x> class FOO {
+public:
+ enum { n = 0 };
+};
+
+template <class A> class BAR {
+public:
+ enum { n = FOO<&A::STATIC>::n };
+};
+
+int n = BAR<U>::n;