OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/tags/gnu-src/gcc-4.5.1/gcc-4.5.1-or32-1.0rc1/gcc/testsuite/g++.old-deja/g++.eh
    from Rev 305 to Rev 338
    Reverse comparison

Rev 305 → Rev 338

/tmpl3.C
0,0 → 1,11
// { dg-do assemble }
 
// Posted by Trevor Taylor <ttaylor@powerup.com.au>
 
template<class T> struct A {
void X() throw(T);
};
 
template<class T>
inline void A<T>::X()
throw(T) { }
tmpl3.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: tmpl5.C =================================================================== --- tmpl5.C (nonexistent) +++ tmpl5.C (revision 338) @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Origin: Mark Mitchell + +template +struct S +{ + void f () + { + try { + } catch (int) { + } + } +};
tmpl5.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch1.C =================================================================== --- catch1.C (nonexistent) +++ catch1.C (revision 338) @@ -0,0 +1,18 @@ +// { dg-do assemble } +// +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 6 Jun 1999 + +// We cannot catch an incomplete type, or ptr to one + +struct A; // { dg-error "" } forward decl + +void fn() +{ + try {} + catch (A *p) {} // { dg-error "" } undefined type + try {} + catch (A p) {} // { dg-error "" } undefined type + try {} + catch (void const *p) {} // ok +}
catch1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch3.C =================================================================== --- catch3.C (nonexistent) +++ catch3.C (revision 338) @@ -0,0 +1,117 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 + +// We cannot catch an ambiguous base class. Check with a non-virtual public +// DAG. +// -- public, << private, == virtual + +// D--B--A +// +--C--A + + +struct A { int m; }; +struct B : A { int m; }; +struct C : A { int m; }; +struct D : B, C { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)d); } + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +}
catch3.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pdel2.C =================================================================== --- pdel2.C (nonexistent) +++ pdel2.C (revision 338) @@ -0,0 +1,23 @@ +// { dg-do run } +// Test for not calling mismatched placement delete. + +#include +#include + +int r = 0; + +struct A { + A() { throw 1; } + void operator delete (void *p, int, long) { r = 1; ::operator delete (p); } +}; + +void * operator new (size_t size, int, int) { return operator new (size); } + +int main () +{ + try { + A* ap = new (1, 5) A; + } catch (...) { } + + return r; +}
pdel2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch5.C =================================================================== --- catch5.C (nonexistent) +++ catch5.C (revision 338) @@ -0,0 +1,154 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// D--B==A +// +--C==A +// +--AA-A + + +struct A { int m; }; +struct B : virtual A { int m; }; +struct C : virtual A { int m; }; +struct AA : A { int m; }; +struct D : B, C, AA { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } +void fnaa(AA *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(AA *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((AA *)d); } + catch(AA *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (AA *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)d); } + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with AA object + caught = 0; + try { fnaa((AA *)d); } + catch(A *p) { caught = 1; if (p != (AA *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnaa((AA *)d); } + catch(AA *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnaa((AA *)d); } + catch(C *p) { abort(); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +}
catch5.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: cleanup2.C =================================================================== --- cleanup2.C (nonexistent) +++ cleanup2.C (revision 338) @@ -0,0 +1,53 @@ +// { dg-do run } +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 21 Nov 1999 + +// make sure we don't call base dtors, if we failed to call the +// base ctor due to exception throwing + +#include + +static bool bad = false; + +static int thrower () +{ + printf ("in %s\n", __PRETTY_FUNCTION__); + throw 0; + return 0; +} + +struct X +{ + X (int) throw (int); + ~X () throw (); +}; + +X::X (int) throw (int) + {printf ("in ctor X %s\n", __PRETTY_FUNCTION__); bad = true;} +X::~X () throw () + {printf ("in dtor X %s\n", __PRETTY_FUNCTION__); bad = true;} + +struct X1 {}; +struct Y : X +{ + Y() throw (int); + ~Y() throw (); +}; +Y::Y() throw (int) + : X(thrower ()) // throws, so X::X is never called + {printf ("in ctor Y%s\n", __PRETTY_FUNCTION__); bad = true;} +Y::~Y() throw () + {printf ("in dtor Y%s\n", __PRETTY_FUNCTION__); bad = true;} + +int main () +{ + try + { + Y y; + } + catch (...) + { + printf ("caught\n"); + } + return bad; +}
cleanup2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch7.C =================================================================== --- catch7.C (nonexistent) +++ catch7.C (revision 338) @@ -0,0 +1,184 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// different levels +// F--D--B--A +// +--C--A +// +--E--A + + +struct A { int m; }; +struct B : A { int m; }; +struct C : A { int m; }; +struct D : B, C { int m; }; +struct E : A { int m; }; +struct F : D, E { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } +void fne(E *obj) { throw obj; } +void fnf(F *obj) { throw obj; } + +extern "C" void abort(); + +void check(F *f) +{ + int caught; + + // try with whole object + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(F *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(E *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with D object + caught = 0; + try { fnd(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with E object + caught = 0; + try { fne(f); } + catch(A *p) { caught = 1; if (p != (E *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(f); } + catch(E *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(f); } + catch(F *p) { abort(); } + catch(...) { caught = 1; } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)f); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)f); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((E *)f); } + catch(E *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (E *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)f); } + catch(A *p) { caught = 1; if (p != (B *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)f); } + catch(B *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)f); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)f); } + catch(A *p) { caught = 1; if (p != (C *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)f); } + catch(C *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)f); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + F f; + check (&f); // try with an object + check ((F *)0); // try with no object + + return 0; +}
catch7.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: terminate2.C =================================================================== --- terminate2.C (nonexistent) +++ terminate2.C (revision 338) @@ -0,0 +1,17 @@ +// { dg-do run } +// Test that an unhandled exception causes us to call terminate. + +#include +#include + +void my_terminate () +{ + std::exit (0); +} + +int main (void) +{ + std::set_terminate (my_terminate); + throw 1; + return 1; +}
terminate2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch9.C =================================================================== --- catch9.C (nonexistent) +++ catch9.C (revision 338) @@ -0,0 +1,117 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// D==B--A +// +==C--A + + +struct A { int m; }; +struct B : A { int m; }; +struct C : A { int m; }; +struct D : virtual B, virtual C { int m; }; + + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)d); } + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(C *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +}
catch9.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: new2.C =================================================================== --- new2.C (nonexistent) +++ new2.C (revision 338) @@ -0,0 +1,47 @@ +// { dg-do run } +// Test that a throw in B's constructor destroys the A and frees the memory. + +#include +#include +#include + +struct A { + A(); + ~A(); +}; + +struct B { + B (A); +}; + +void foo (B*); + +int newed, created; + +int main () +{ + newed = 0; // The libraries might call new before main starts. + 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 *) std::malloc (size); +} + +void operator delete (void *p) throw () +{ + --newed; + free (p); +} +
new2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: rethrow2.C =================================================================== --- rethrow2.C (nonexistent) +++ rethrow2.C (revision 338) @@ -0,0 +1,46 @@ +// { dg-do run } +// Testcase for proper handling of rethrow. + +#include + +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; + } + } + } + catch (A) + { + printf ("Caught.\n"); + } + printf ("c == %d, d == %d\n", c, d); + return c != d; +}
rethrow2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: rethrow4.C =================================================================== --- rethrow4.C (nonexistent) +++ rethrow4.C (revision 338) @@ -0,0 +1,46 @@ +// { dg-do run } +// Testcase for proper handling of rethrow. + +#include + +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; +}
rethrow4.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: rethrow6.C =================================================================== --- rethrow6.C (nonexistent) +++ rethrow6.C (revision 338) @@ -0,0 +1,76 @@ +// { dg-do run } +// Testcase for proper handling of rethrow. + +#include + +int c, d; +int wrong; + +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; } +}; + +struct B +{ + ~B () { + try + { + printf ("Rethrowing III...\n"); + throw; + } + catch (A& a) + { + printf ("Caught III %d...\n", a.i); + if (a.i != 1) + { + printf ("** rethrew uncaught exception **\n"); + wrong = 1; + } + } + printf ("continuing to unwind II...\n"); + } +}; + +int +main () +{ + { + A a; + + try + { + try + { + printf ("Throwing I...\n"); + throw a; + } + catch (A& a) + { + printf ("Caught I %d...\n", a.i); + try + { + B b; + printf ("Throwing II...\n"); + throw a; + } + catch (A& a) + { + printf ("Caught II %d...\n", a.i); + printf ("Throwing IV...\n"); + throw; + } + } + } + catch (A& a) + { + printf ("Caught IV %d.\n", a.i); + } + } + + printf ("c == %d, d == %d\n", c, d); + return c != d || wrong; +}
rethrow6.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch4p.C =================================================================== --- catch4p.C (nonexistent) +++ catch4p.C (revision 338) @@ -0,0 +1,114 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 + +// We cannot catch an ambiguous base class. Check with a virtual +// polymorphic public DAG. +// -- public, << private, == virtual + +// D--B==A +// +--C==A + + +struct A { int m; virtual ~A(){}}; +struct B : virtual A { int m; }; +struct C : virtual A { int m; }; +struct D : B, C { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)d); } + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +}
catch4p.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch8p.C =================================================================== --- catch8p.C (nonexistent) +++ catch8p.C (revision 338) @@ -0,0 +1,111 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 6 Jun 1999 + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// D--B--A +// +--C<
catch8p.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: inline2.C =================================================================== --- inline2.C (nonexistent) +++ inline2.C (revision 338) @@ -0,0 +1,25 @@ +// { dg-do run } +// { dg-options "-O" } +// Test that inlining a destructor with a catch block doesn't confuse the +// enclosing try block. + +struct A { + ~A() + { + try { throw 1; } + catch (...) { } + } +}; + +int main () +{ + try + { + A a; + throw 42; + } + catch (int i) + { + return (i != 42); + } +}
inline2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: spec1.C =================================================================== --- spec1.C (nonexistent) +++ spec1.C (revision 338) @@ -0,0 +1,39 @@ +// { dg-do run } +// Testing exception specifications. +// Test 1: the original exception succeeds. + +#include +#include + +void my_term () { exit (1); } +void my_unexp () { throw 42; } + +void +f () throw (char, int, std::bad_exception) +{ + throw 'a'; +} + +int main () +{ + std::set_terminate (my_term); + std::set_unexpected (my_unexp); + + try + { + f (); + } + catch (char) + { + return 0; + } + catch (int) + { + return 3; + } + catch (std::bad_exception) + { + return 4; + } + return 5; +}
spec1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: spec3.C =================================================================== --- spec3.C (nonexistent) +++ spec3.C (revision 338) @@ -0,0 +1,39 @@ +// { dg-do run } +// Testing exception specifications. +// Test 3: the bad_exception throw succeeds. + +#include +#include + +void my_term () { exit (1); } +void my_unexp () { throw 42; } + +void +f () throw (std::bad_exception) +{ + throw 'a'; +} + +int main () +{ + std::set_terminate (my_term); + std::set_unexpected (my_unexp); + + try + { + f (); + } + catch (char) + { + return 2; + } + catch (int) + { + return 3; + } + catch (std::bad_exception) + { + return 0; + } + return 5; +}
spec3.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: spec5.C =================================================================== --- spec5.C (nonexistent) +++ spec5.C (revision 338) @@ -0,0 +1,3 @@ +// { dg-do assemble } + +extern void *f(unsigned int k) throw();
spec5.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: spec7.C =================================================================== --- spec7.C (nonexistent) +++ spec7.C (revision 338) @@ -0,0 +1,20 @@ +// { dg-do run } +// Test that we allow simple throw specs on pointers. + +void f() throw () { } +void (*pf)() throw () = f; + +struct A +{ + void g() throw () { } + static void (A::*pmf)() throw (); +}; + +void (A::* A::pmf)() = &A::g; + +int main() +{ + pf (); + A a; + (a.*A::pmf)(); +}
spec7.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: crash2.C =================================================================== --- crash2.C (nonexistent) +++ crash2.C (revision 338) @@ -0,0 +1,27 @@ +// { dg-do assemble } +// { dg-options "-O" } +// Origin: Thomas Kunert + +struct C { + ~C(); +}; + +struct R { + bool empty() const; + C m_; +}; + +struct R1 { + R1( const R& a ); + ~R1 (); + C m_; +}; + +R1 get_empty(); + +R1::R1( const R& a ) : + m_( a.empty() ? get_empty().m_ : C() ) +{} + +void qnorm( const R & r) +{ R1 n( r ); }
crash2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: vbase2.C =================================================================== --- vbase2.C (nonexistent) +++ vbase2.C (revision 338) @@ -0,0 +1,35 @@ +// { dg-do run } +// Origin: Mark Mitchell + +int i; + +struct A +{ + A () { i++; } + ~A () { i--; } +}; + +struct B : public virtual A +{ + B () { throw 1; } +}; + +struct D: public B, virtual public A +{ +}; + +void f() +{ + D d; +} + +int main () +{ + try { + f(); + } catch (int) { + } + + return i; +} +
vbase2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch10.C =================================================================== --- catch10.C (nonexistent) +++ catch10.C (revision 338) @@ -0,0 +1,22 @@ +// { dg-do assemble } +// Test that we notice unfortunate handler ordering. + +struct A { }; +struct B: public A { }; +struct C: private A { }; + +void f(); +void g() +{ + try { f(); } + catch (...) { } // { dg-error "" } ... followed by others + catch (A*) { } + + try { f(); } + catch (A*) { } // { dg-warning "" } A* before B* + catch (B*) { } // { dg-warning "" } A* before B* + + try { f(); } + catch (A*) { } + catch (C*) { } // no warning; A is private base +}
catch10.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: throw1.C =================================================================== --- throw1.C (nonexistent) +++ throw1.C (revision 338) @@ -0,0 +1,12 @@ +// { dg-do assemble } + +void athrow(const int & e) throw(int) +{ + throw e; +} + +int main(void) +{ + athrow(int()); + return 0; +}
throw1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: crash4.C =================================================================== --- crash4.C (nonexistent) +++ crash4.C (revision 338) @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "-O2" } +// Origin: Nathan Sidwell + +struct A +{ + A (int) { } + ~A () { } + int get () const { return 0; } +}; + +void f (const A &s) { + f (s.get ()); +}
crash4.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: vbase4.C =================================================================== --- vbase4.C (nonexistent) +++ vbase4.C (revision 338) @@ -0,0 +1,40 @@ +// { dg-do run } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 8 Mar 2000 + +// Derived from PR#7 + +// We need to destroy the thrown object when exiting the catch +// clause. That needs to destroy the original thrown object, not +// the caught one (which might be a base). + +static int ok = 0; + +struct A +{ + A (){} + virtual ~A () {} +}; + +struct B : virtual A +{ + int value; + B () + :value(10) + {} + ~B() + { + if (value == 10) + ok = 1; + } +}; + +int main() +{ + try { + throw B (); + } catch (A & e) { + } + return !ok; +}
vbase4.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ptrmem1.C =================================================================== --- ptrmem1.C (nonexistent) +++ ptrmem1.C (revision 338) @@ -0,0 +1,16 @@ +// { dg-do run } +extern "C" void exit (int); +extern "C" void abort (void); +struct A { int i; }; +int main () +{ + try { throw &A::i; } + catch (int A::*p) + { + if (p == &A::i) + exit (0); + else + abort (); + } + abort (); +}
ptrmem1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch3p.C =================================================================== --- catch3p.C (nonexistent) +++ catch3p.C (revision 338) @@ -0,0 +1,117 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 + +// We cannot catch an ambiguous base class. Check with a non-virtual +// polymorphic public DAG. +// -- public, << private, == virtual + +// D--B--A +// +--C--A + + +struct A { int m; virtual ~A(){}}; +struct B : A { int m; }; +struct C : A { int m; }; +struct D : B, C { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)d); } + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +}
catch3p.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch12.C =================================================================== --- catch12.C (nonexistent) +++ catch12.C (revision 338) @@ -0,0 +1,64 @@ +// { dg-do run } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 24 May 2000 + +// we should be able to catch a base a virtual, provided it is accessible by at +// least one public path +// -- public, << private, == virtual +// E--B<<==A +// +--C--==A +// +--D<<==A + +struct A {}; +struct B : private virtual A {}; +struct C : virtual A {}; +struct D : private virtual A {}; +struct E : public B, public C, public D {}; + +extern "C" void abort (); + +void fne (E *e) +{ + throw e; +} + +void check(E *e) +{ + int caught; + + caught = 0; + try { fne(e); } + catch(A *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(B *p) { caught = 1; if (p != e) abort();} + catch(...) { abort (); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(C *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(D *p) { caught = 1; if (p != e) abort ();} + catch(...) { abort (); } + if (!caught) abort(); + + return; +} + +int main () +{ + E e; + + check (&e); + check ((E *)0); + + return 0; +}
catch12.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ptr1.C =================================================================== --- ptr1.C (nonexistent) +++ ptr1.C (revision 338) @@ -0,0 +1,23 @@ +// { dg-do run } +// 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%lx\n", (__SIZE_TYPE__)e); + return !((__SIZE_TYPE__)e != 5 && e->x == 5); + } + return 2; +}
ptr1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: crash6.C =================================================================== --- crash6.C (nonexistent) +++ crash6.C (revision 338) @@ -0,0 +1,26 @@ +// { dg-do assemble } +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 26 April 2001 +// Origin: schmid@snake.iap.physik.tu-darmstadt.de + +// Bug 2368. When checking shadowed catchers, we didn't ignore +// template type parms etc, leading to an ICE + +template +void call(int& a) +{ + try + { + + } + catch (CatchType1&) + { + + } + catch (CatchType2&) + { + + } +} +
crash6.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch14.C =================================================================== --- catch14.C (nonexistent) +++ catch14.C (revision 338) @@ -0,0 +1,33 @@ +// { dg-do assemble } +// { dg-options "-O1" } +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Jakub Jelinek 2 May 2001 + + +void foo(); + +struct A { + A (int x) { }; + ~A() { + try { + foo (); + } catch (...) { } + }; +}; + +struct B; + +B *x; + +struct B { + void a(); + void b(); + static B* c() { + A y = 0; + return x; + }; +}; + +void B::a() { + c()->b(); +}
catch14.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catchptr1.C =================================================================== --- catchptr1.C (nonexistent) +++ catchptr1.C (revision 338) @@ -0,0 +1,262 @@ +// { dg-do run } +// Test pointer chain catching +// Copyright (C) 2000, 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 9 Apr 2000 + +#include + +void fn () {} +struct A {void fn () {}}; +static int var = 1; +static const int const_var = 2; + +struct B; +struct C; + +int test0 () +{ + try + { + throw &fn; + } + catch (void *) + { + // should not decay to void * + return 1; + } + catch (...) + { + return 0; + } + return -1; +} + +int test1 () +{ + try + { + throw &A::fn; + } + catch (void *) + { + // should not decay to void * + return 1; + } + catch (...) + { + return 0; + } + return -1; +} + +int test2 () +{ + try + { + throw &var; + } + catch (void *) + { + // should decay to void * + return 0; + } + catch (...) + { + return 1; + } + return -1; +} + +int test3 () +{ + try + { + throw &var; + } + catch (void const *) + { + // should decay to const void * + return 0; + } + catch (...) + { + return 1; + } + return -1; +} + +int test4 () +{ + try + { + throw &const_var; + } + catch (void *) + { + // should not decay to void * + return 1; + } + catch (void const *) + { + // should decay to const void * + return 0; + } + catch (...) + { + return 2; + } + return -1; +} + +int test5 () +{ + try + { + throw (void ***)0; + } + catch (void ***) + { + return 0; + } + catch (...) + { + return 1; + } + return -1; +} + +int test6 () +{ + try + { + throw (void const* const* const*)0; + } + catch (void ***) + { + return 1; + } + catch (void * const* const*) + { + return 2; + } + catch (void const* * const*) + { + return 3; + } + catch (void const* const* *) + { + return 4; + } + catch (void const* const* const *) + { + return 0; + } + catch (...) + { + return 1; + } + return -1; +} + +int test7 () +{ + try + { + throw (void ***)0; + } + catch (void const* const**) + { + return 1; + } + catch (void const** const *) + { + return 2; + } + catch (void * const* const *) + { + return 0; + } + catch (...) + { + return 3; + } + return -1; +} + +int test8 () +{ + try + { + throw (B **)0; + } + catch (C **) + { + return 1; + } + catch (B **) + { + return 0; + } + catch (...) + { + return 2; + } + return -1; +} + +int test9 () +{ + try + { + throw (B **)0; + } + catch (C const *const *) + { + return 1; + } + catch (B const *const *) + { + return 0; + } + catch (...) + { + return 2; + } + return -1; +} + +static int (*tests[])() = +{ + test0, + test1, + test2, + test3, + test4, + + test5, + test6, + test7, + + test8, + test9, + + NULL +}; + +int main () +{ + int ix; + int errors = 0; + + for (ix = 0; tests[ix]; ix++) + { + int n = tests[ix] (); + + if (n) + { + printf ("test %d failed %d\n", ix, n); + errors++; + } + } + return errors; +}
catchptr1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch7p.C =================================================================== --- catch7p.C (nonexistent) +++ catch7p.C (revision 338) @@ -0,0 +1,184 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// different levels +// F--D--B--A +// +--C--A +// +--E--A + + +struct A { int m; virtual ~A(){}}; +struct B : A { int m; }; +struct C : A { int m; }; +struct D : B, C { int m; }; +struct E : A { int m; }; +struct F : D, E { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } +void fne(E *obj) { throw obj; } +void fnf(F *obj) { throw obj; } + +extern "C" void abort(); + +void check(F *f) +{ + int caught; + + // try with whole object + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(F *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(E *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with D object + caught = 0; + try { fnd(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with E object + caught = 0; + try { fne(f); } + catch(A *p) { caught = 1; if (p != (E *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(f); } + catch(E *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(f); } + catch(F *p) { abort(); } + catch(...) { caught = 1; } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)f); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)f); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((E *)f); } + catch(E *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (E *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)f); } + catch(A *p) { caught = 1; if (p != (B *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)f); } + catch(B *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)f); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)f); } + catch(A *p) { caught = 1; if (p != (C *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)f); } + catch(C *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)f); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + F f; + check (&f); // try with an object + check ((F *)0); // try with no object + + return 0; +}
catch7p.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: tmpl2.C =================================================================== --- tmpl2.C (nonexistent) +++ tmpl2.C (revision 338) @@ -0,0 +1,32 @@ +// { dg-do assemble } +// { dg-options "-O" } + +// Posted by H. J. Lu + +template +class FixSeq +{ +public: + void append(const T&); +}; +class foo +{ +public: + void setupIR(); +}; +typedef FixSeq bar; +extern void dummy (foo *); +void * +foobar (bar &x, foo *p) +{ + try + { + p -> setupIR(); + } + catch(...) + { + dummy (p); + } + x.append(p); + return p; +}
tmpl2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: tmpl4.C =================================================================== --- tmpl4.C (nonexistent) +++ tmpl4.C (revision 338) @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Origin: Mark Mitchell + +template void test(){ + try { + } + catch(int x){ + } +} + +template void test();
tmpl4.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ia64-1.C =================================================================== --- ia64-1.C (nonexistent) +++ ia64-1.C (revision 338) @@ -0,0 +1,73 @@ +// { dg-do run } +// { dg-options "-O2" } + +#include + +using namespace std; + +extern "C" void abort(); + +int i_0, i_1, i_2, i_3, i_4, i_5, i_6, i_7, i_8, i_9; +int j_0, j_1, j_2, j_3, j_4, j_5, j_6, j_7, j_8, j_9; +int k_0, k_1, k_2, k_3, k_4, k_5, k_6, k_7, k_8, k_9; +int l_0, l_1, l_2, l_3, l_4, l_5, l_6, l_7, l_8, l_9; +#define A(x,y,n) register int *x##n = &y##_##n; +#define B(x,y) \ + A(x,y,0) A(x,y,1) A(x,y,2) A(x,y,3) A(x,y,4) \ + A(x,y,5) A(x,y,6) A(x,y,7) A(x,y,8) A(x,y,9) +#define C(x,n) asm volatile ("" : "=r" (x##n) : "0" (x##n)); +#define D(x) \ + C(x,0) C(x,1) C(x,2) C(x,3) C(x,4) \ + C(x,5) C(x,6) C(x,7) C(x,8) C(x,9) +#define E(x,y,n) if (x##n != &y##_##n) abort (); +#define F(x,y) \ + E(x,y,0) E(x,y,1) E(x,y,2) E(x,y,3) E(x,y,4) \ + E(x,y,5) E(x,y,6) E(x,y,7) E(x,y,8) E(x,y,9) + +void bar(long a0, long a1, long a2, long a3, long a4) +{ +} + +void foo(long a0, long a1, long a2, long a3, long a4) +{ + A(p,l,0) A(p,l,1) A(p,l,2) + C(p,0) C(p,1) C(p,2) + bar (0, 1, 2, 3, 4); + if (a0 == 0) + throw exception(); + C(p,0) C(p,1) C(p,2) + E(p,l,0) E(p,l,1) E(p,l,2) +} + +void test(void) +{ + A(p,l,0) A(p,l,1) A(p,l,2) A(p,l,3) A(p,l,4) A(p,l,5) A(p,l,6) + C(p,0) C(p,1) C(p,2) C(p,3) C(p,4) C(p,5) C(p,6) + try { + foo(0, 1, 2, 3, 4); + } catch (exception) {} + C(p,0) C(p,1) C(p,2) C(p,3) C(p,4) C(p,5) C(p,6) + E(p,l,0) E(p,l,1) E(p,l,2) E(p,l,3) E(p,l,4) E(p,l,5) E(p,l,6) +} + +int main() +{ + B(x,i) + B(y,j) + B(z,k) + A(p,l,0) A(p,l,1) A(p,l,2) A(p,l,3) + D(x) + D(y) + D(z) + C(p,0) C(p,1) C(p,2) C(p,3) + test(); + D(x) + D(y) + D(z) + C(p,0) C(p,1) C(p,2) C(p,3) + F(x,i) + F(y,j) + F(z,k) + E(p,l,0) E(p,l,1) E(p,l,2) E(p,l,3) + return 0; +}
ia64-1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: tmpl6.C =================================================================== --- tmpl6.C (nonexistent) +++ tmpl6.C (revision 338) @@ -0,0 +1,18 @@ +// { dg-do assemble } +// Origin: Mark Mitchell + +struct S +{ + int i; +}; + +template +void f () +{ + try { + } catch (S& s) { + s.i = 3; + } +} + +template void f();
tmpl6.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch2.C =================================================================== --- catch2.C (nonexistent) +++ catch2.C (revision 338) @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Origin: Mike Danylchuk + +typedef char TCHAR; + +int main() +{ + try {} + catch( TCHAR* Err ) {} +} +
catch2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pdel1.C =================================================================== --- pdel1.C (nonexistent) +++ pdel1.C (revision 338) @@ -0,0 +1,23 @@ +// { dg-do run } +// Test for calling placement delete. + +#include +#include + +int r = 1; + +struct A { + A() { throw 1; } + void operator delete (void *p, int, int) { r = 0; ::operator delete (p); } +}; + +void * operator new (size_t size, int, int) { return operator new (size); } + +int main () +{ + try { + A* ap = new (1, 5) A; + } catch (...) { } + + return r; +}
pdel1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch4.C =================================================================== --- catch4.C (nonexistent) +++ catch4.C (revision 338) @@ -0,0 +1,114 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 + +// We cannot catch an ambiguous base class. Check with a virtual public +// DAG. +// -- public, << private, == virtual + +// D--B==A +// +--C==A + + +struct A { int m; }; +struct B : virtual A { int m; }; +struct C : virtual A { int m; }; +struct D : B, C { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)d); } + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +}
catch4.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: cleanup1.C =================================================================== --- cleanup1.C (nonexistent) +++ cleanup1.C (revision 338) @@ -0,0 +1,35 @@ +// { dg-do run } +// 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; +}
cleanup1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch6.C =================================================================== --- catch6.C (nonexistent) +++ catch6.C (revision 338) @@ -0,0 +1,185 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// E==D--B==A +// +--C==A +// +--AA-A + + +struct A { int m; }; +struct B : virtual A { int m; }; +struct C : virtual A { int m; }; +struct AA : A { int m; }; +struct D : B, C, AA { int m; }; +struct E : virtual D { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } +void fnaa(AA *obj) { throw obj; } +void fne(E *obj) { throw obj; } + +extern "C" void abort(); + +void check(E *e) +{ + int caught; + + // try with whole object + caught = 0; + try { fne(e); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(A *p) { abort(); } // A is ambiguous + catch(AA *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with D oject + caught = 0; + try { fnd((D *)e); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd((D *)e); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd((D *)e); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd((D *)e); } + catch(A *p) { abort(); } // A is ambiguous + catch(AA *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)e); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)e); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((AA *)e); } + catch(AA *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (AA *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)e); } + catch(A *p) { caught = 1; if (p != (B *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)e); } + catch(B *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)e); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)e); } + catch(A *p) { caught = 1; if (p != (C *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)e); } + catch(C *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)e); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with AA object + caught = 0; + try { fnaa((AA *)e); } + catch(A *p) { caught = 1; if (p != (AA *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnaa((AA *)e); } + catch(AA *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnaa((AA *)e); } + catch(C *p) { abort(); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + E e; + check (&e); // try with an object + check ((E *)0); // try with no object + + return 0; +}
catch6.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: terminate1.C =================================================================== --- terminate1.C (nonexistent) +++ terminate1.C (revision 338) @@ -0,0 +1,28 @@ +// { dg-do run } +// Test that an exception thrown out of the constructor for the exception +// object (i.e. "after completing evaluation of the expression to be thrown +// but before the exception is caught") causes us to call terminate. + +#include +#include + +void my_terminate () +{ + std::exit (0); +} + +struct A +{ + A () {} + A (const A&) { throw 1; } +}; + +int main (void) +{ + std::set_terminate (my_terminate); + + A a; + try { throw a; } + catch (...) {} + return 1; +}
terminate1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch8.C =================================================================== --- catch8.C (nonexistent) +++ catch8.C (revision 338) @@ -0,0 +1,110 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 6 Jun 1999 + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// D--B--A +// +--C<
catch8.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: new1.C =================================================================== --- new1.C (nonexistent) +++ new1.C (revision 338) @@ -0,0 +1,49 @@ +// { dg-do run } +// Test that a throw in foo destroys the A, but does not free the memory. + +#include +#include +#include + +struct A { + A(); + ~A(); +}; + +struct B { + B (A); +}; + +void foo (B*); + +int newed, created; + +int 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 *) std::malloc (size); +} + +void operator delete (void *p) throw () +{ + --newed; + std::free (p); +} + + + +
new1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: rethrow1.C =================================================================== --- rethrow1.C (nonexistent) +++ rethrow1.C (revision 338) @@ -0,0 +1,46 @@ +// { dg-do run } +// Testcase for proper handling of rethrow. + +#include + +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 A(); + } + catch (A) + { + printf ("Throwing 3...\n"); + throw; + } + } + } + catch (A) + { + printf ("Caught.\n"); + } + printf ("c == %d, d == %d\n", c, d); + return c != d; +}
rethrow1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: rethrow3.C =================================================================== --- rethrow3.C (nonexistent) +++ rethrow3.C (revision 338) @@ -0,0 +1,40 @@ +// { dg-do run } +#include +#include +#include + +static void +eh_terminate () +{ + printf ("CALLING TERMINATE\n"); + exit (1); +} + +void +eh_test (int level) +{ + try + { + if (level < 2) + eh_test (level + 1); + else + { + printf ("%d: Throwing\n", level); + throw (level); + } + } + catch (int &x) + { + printf ("%d: Got level %d\n", + level, x); + + if (level > 0) + throw; + } +} + +int main () +{ + std::set_terminate (&eh_terminate); + eh_test (0); +}
rethrow3.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: rethrow5.C =================================================================== --- rethrow5.C (nonexistent) +++ rethrow5.C (revision 338) @@ -0,0 +1,45 @@ +// { dg-do run } +// Testcase for proper handling of rethrow. + +#include + +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; +}
rethrow5.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: unwind1.C =================================================================== --- unwind1.C (nonexistent) +++ unwind1.C (revision 338) @@ -0,0 +1,25 @@ +// { dg-do run } +// Test that unwinding properly restores SP. +// Contributed by Jason Merrill + +void f (int i) +{ + throw i; +} + +int main () +{ + void *sp1 = __builtin_alloca (0); + + try + { + f (0); + } + catch (int) + { + } + + void *sp2 = __builtin_alloca (0); + + return (sp1 != sp2); +}
unwind1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch6p.C =================================================================== --- catch6p.C (nonexistent) +++ catch6p.C (revision 338) @@ -0,0 +1,185 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// E==D--B==A +// +--C==A +// +--AA-A + + +struct A { int m; virtual ~A(){}}; +struct B : virtual A { int m; }; +struct C : virtual A { int m; }; +struct AA : A { int m; }; +struct D : B, C, AA { int m; }; +struct E : virtual D { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } +void fnaa(AA *obj) { throw obj; } +void fne(E *obj) { throw obj; } + +extern "C" void abort(); + +void check(E *e) +{ + int caught; + + // try with whole object + caught = 0; + try { fne(e); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(A *p) { abort(); } // A is ambiguous + catch(AA *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with D oject + caught = 0; + try { fnd((D *)e); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd((D *)e); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd((D *)e); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd((D *)e); } + catch(A *p) { abort(); } // A is ambiguous + catch(AA *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)e); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)e); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((AA *)e); } + catch(AA *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (AA *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)e); } + catch(A *p) { caught = 1; if (p != (B *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)e); } + catch(B *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)e); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)e); } + catch(A *p) { caught = 1; if (p != (C *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)e); } + catch(C *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)e); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with AA object + caught = 0; + try { fnaa((AA *)e); } + catch(A *p) { caught = 1; if (p != (AA *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnaa((AA *)e); } + catch(AA *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnaa((AA *)e); } + catch(C *p) { abort(); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + E e; + check (&e); // try with an object + check ((E *)0); // try with no object + + return 0; +}
catch6p.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ctor1.C =================================================================== --- ctor1.C (nonexistent) +++ ctor1.C (revision 338) @@ -0,0 +1,17 @@ +// { dg-do assemble } +struct A +{ + A(); // { dg-message "" } candidate + A(A&); // { dg-message "candidates" } referenced below +}; + +int +main () +{ + try + { + throw A(); // { dg-error "no matching" "match" } can't copy +// { dg-error "thrown expression" "expr" { target *-*-* } 13 } + } + catch (...) { } +}
ctor1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: inline1.C =================================================================== --- inline1.C (nonexistent) +++ inline1.C (revision 338) @@ -0,0 +1,25 @@ +// { dg-do assemble } +// { dg-options "-ansi -pedantic-errors -O2" } +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Nov 1999 + + +struct Foo +{ + inline ~Foo (); +}; + +inline void Wibble (int) throw () +{ +} + +inline Foo::~Foo () +{ + Wibble (6); +} + +int ExtendFoos () +{ + Foo tmp; + return 0; +}
inline1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: cond1.C =================================================================== --- cond1.C (nonexistent) +++ cond1.C (revision 338) @@ -0,0 +1,31 @@ +// { dg-do assemble } + +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 11 Apr 1999 +// Derived from bug report from Gabriel Dos Reis +// +// http://gcc.gnu.org/ml/gcc-bugs/1999-03n/msg00888.html + +// conditional exprs have some funny rules when one of the types is void. +// [expr.cond] 5.16, make sure we do the right things +// We implement an extension, allowing one side to be void, check we +// pedantically moan. + +struct X {}; +void fn(int i) +{ + int j; + + j = (i ? throw X() : 1); // ok, int + j = (i ? 1 : throw X()); // ok, int + + (i ? throw X() : throw X()); // ok, void + + (i ? i : j) = 1; // ok, int & + (i ? throw X() : j) = 1; // { dg-error "" } non-lvalue + (i ? j : throw X()) = 1; // { dg-error "" } non-lvalue + (i ? throw X() : throw X()) = 1; // { dg-error "" } void + + (i ? (void)1 : i++); // { dg-error "" } ANSI forbids + (i ? i++ : (void)1); // { dg-error "" } ANSI forbids +}
cond1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: spec2.C =================================================================== --- spec2.C (nonexistent) +++ spec2.C (revision 338) @@ -0,0 +1,39 @@ +// { dg-do run } +// Testing exception specifications. +// Test 2: the second throw succeeds. + +#include +#include + +void my_term () { exit (1); } +void my_unexp () { throw 42; } + +void +f () throw (int, std::bad_exception) +{ + throw 'a'; +} + +int main () +{ + std::set_terminate (my_term); + std::set_unexpected (my_unexp); + + try + { + f (); + } + catch (char) + { + return 2; + } + catch (int) + { + return 0; + } + catch (std::bad_exception) + { + return 4; + } + return 5; +}
spec2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: spec4.C =================================================================== --- spec4.C (nonexistent) +++ spec4.C (revision 338) @@ -0,0 +1,39 @@ +// { dg-do run } +// Testing exception specifications. +// Test 4: all throws fail, call terminate. + +#include +#include + +void my_term () { exit (0); } +void my_unexp () { throw 42; } + +void +f () throw (short) +{ + throw 'a'; +} + +int main () +{ + std::set_terminate (my_term); + std::set_unexpected (my_unexp); + + try + { + f (); + } + catch (char) + { + return 2; + } + catch (int) + { + return 3; + } + catch (std::bad_exception) + { + return 4; + } + return 5; +}
spec4.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: spec6.C =================================================================== --- spec6.C (nonexistent) +++ spec6.C (revision 338) @@ -0,0 +1,137 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 19 Jan 1999 + +// Determine that throw specifiers are checked correctly. + +// [except.spec] 1, a type in an exception specifier shall not be incomplete, +// or pointer or ref to incomplete +struct X; // { dg-error "" } forward declaration.* +void fn1() throw(X); // { dg-error "" } invalid use of undefined type +void fn2() throw(X *); // { dg-error "" } invalid use of undefined type +void fn3() throw(X &); // { dg-error "" } invalid use of undefined tyoe +void fn4() throw(void); // { dg-error "" } invalid use of void expression +void fn5() throw(void &); // { dg-error "" } invalid type // ERROR - invalid use of void +// except for cv pointer to void +void fn6() throw(void *); // ok -- pointer to void +void fn7() throw(void const *); // ok -- pointer to cv void + +template void fny() throw(T); // ok (so far) +template<> void fny() throw(int); // ok +template<> void fny() throw(void); // { dg-error "" } invalid use of void + +template void fnx(T *) throw(T){} // { dg-error "" } invalid use of void expression +void fx() +{ + fnx((int *)0); + fnx((void *)0); // { dg-message "instantiated from here" } +} + +// [except.spec] 2, exception specifiers must be the same set of types (but +// can be reordered) +void baz1() throw(int, char); +void baz1() throw(char, int){} // reordering is ok + +void baz2() throw(int, char); +void baz2() throw(int, char, int){} // duplicates are ignored + +typedef int Int; +void baz3() throw(int, char); +void baz3() throw(Int, char){} // typedefs are the same type ... + +void baz4() throw(int, Int, char); // ... so this is a duplicate +void baz4() throw(Int, char){} + +void fna() throw(int, char); // { dg-error "" } to previous declaration +void fna() throw(int const, char); // { dg-error "" } declaration different exceptions // ERROR - to previous declaration +void fna() throw(int){} // { dg-error "" } declaration different exceptions + +void fnb() throw(int, char); // { dg-error "" } to previous declaration +void fnb() throw(char){} // { dg-error "" } declaration different exceptions + +void fnc() throw(int, char); // { dg-error "" } to previous declaration +void fnc() throw(char, int, float){} // { dg-error "" } declaration different exceptions + +void fnd() throw(); // { dg-error "" } to previous declaration +void fnd() throw(char){} // { dg-error "" } declaration different exceptions + +void fne() throw(char); // { dg-error "" } to previous declaration +void fne() throw(){} // { dg-error "" } declaration different exceptions + +void fnf(); // { dg-error "" } to previous declaration +void fnf() throw(char){} // { dg-error "" } declaration different exceptions + +void fng() throw(char); // { dg-error "" } to previous declaration +void fng(){} // { dg-error "" } declaration different exceptions + +void fnh() throw(int, char); // { dg-error "" } to previous declaration +void fnh() throw(int, float){} // { dg-error "" } declaration different exceptions + +void fni() throw(int, char); // { dg-error "" } to previous declaration +void fni() throw(float, char){} // { dg-error "" } declaration different exceptions + +// [except.spec] 3, virtual function overriders shall throw a subset of the +// overridden function +struct E {}; +struct F : public E {}; +struct F1 : public E {}; +struct G : public F, F1 {}; +struct H : private E {}; +struct A +{ + virtual void foo() throw(); // { dg-error "" } overriding + virtual void baz() throw(double, int); + virtual void bar(); + virtual void qux() throw(E); + virtual void qux(int) throw(E const *); // { dg-error "" } overriding (pedantically) + virtual void quux() throw(F); // { dg-error "" } overriding + virtual void quux(int) throw(F *); // { dg-error "" } overriding + virtual void wibble() throw(E); // { dg-error "" } overriding + virtual void wobble() throw(E *); // { dg-error "" } overriding + virtual void wobble(int) throw(E *); // { dg-error "" } overriding + virtual void wabble(int) throw(E *); + virtual void wubble(int) throw(E *, H *); + virtual ~A() throw(); // { dg-error "" } overriding +}; + +struct B : A +{ + virtual void foo() throw(int); // { dg-error "" } looser throw - A::foo + virtual void baz() throw(double); // ok subset + virtual void bar(int) throw(int); // ok not overriding + virtual void qux() throw(F); // ok subset + virtual void qux(int) throw(F *); // { dg-error "" } looser (pedantically) + virtual void quux() throw(E); // { dg-error "" } looser throw - A::quux() + virtual void quux(int) throw(E *); // { dg-error "" } looser throw - A::quux(int) + virtual void wibble() throw(E *); // { dg-error "" } looser throw - A::wibble + virtual void wobble() throw(G *); // { dg-error "" } looser throw - A::wobble() + virtual void wobble(int) throw(H *); // { dg-error "" } looser throw - A::wobble(int) + virtual void wubble(int) throw(H *); // ok + virtual void wabble(int) throw(F1 *, F *); // ok +}; + +struct A1 +{ + virtual void foo() throw(int); + virtual void bar() throw(); // { dg-error "" } overriding + virtual ~A1() throw(int); +}; + +struct B1 : A +{ +}; + +struct C : A, A1 +{ // { dg-error "" } looser throw - A::~A() + virtual void foo() throw(int); // { dg-error "" } looser throw - A::foo + virtual void bar() throw(int); // { dg-error "" } looser throw - A1::bar +}; + +struct D : A, A1 +{ + virtual ~D() throw(int); // { dg-error "" } looser throw - A::~A() +}; + +// [except.spec] 5, types shall not be defined in exception specifiers +void fn8() throw(struct Z {}); // { dg-error "" } ANSI C++ forbids
spec6.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: vbase1.C =================================================================== --- vbase1.C (nonexistent) +++ vbase1.C (revision 338) @@ -0,0 +1,25 @@ +// { dg-do run } +// Origin: Mark Mitchell + +int i; +int j; + +struct B +{ + B() { i = 1; } + ~B() { j = 7; } +}; + +struct D : virtual public B { + D () { throw 3; } +}; + +int main () +{ + try { + D d; + } catch (int) { + if (i != 1 || j != 7) + return 1; + } +}
vbase1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: crash1.C =================================================================== --- crash1.C (nonexistent) +++ crash1.C (revision 338) @@ -0,0 +1,22 @@ +// { dg-do assemble } +// { dg-options "-O1 -fno-inline-functions" } + +struct A +{ + ~A (); +}; + +bool foo (); + +int i; +int j; + +A bar () +{ + for (i = 0; i < 1; ++i) + if (j) + { + A tmp; + return tmp; + } +}
crash1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: badalloc1.C =================================================================== --- badalloc1.C (nonexistent) +++ badalloc1.C (revision 338) @@ -0,0 +1,133 @@ +// This fails for VxWorks RTPs because the initialization of +// __cxa_allocate_exception's emergency buffer mutex will +// itself call malloc(), and will fail if there is no more +// memory available. +// { dg-do run { xfail { { xstormy16-*-* *-*-darwin[3-7]* } || vxworks_rtp } } } +// Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 6 June 2000 + +// Check we can throw a bad_alloc exception when malloc dies. + +typedef __SIZE_TYPE__ size_t; +extern "C" void abort(); +extern "C" void *memcpy(void *, const void *, size_t); + +// Assume that STACK_SIZE defined implies a system that does not have a +// large data space either, and additionally that we're not linking against +// a shared libstdc++ (which requires quite a bit more initialization space). +#ifdef STACK_SIZE +const int arena_size = 256; +#else +#if defined(__FreeBSD__) || defined(__sun__) || defined(__hpux__) +// FreeBSD, Solaris and HP-UX with threads require even more +// space at initialization time. FreeBSD 5 now requires over 131072 bytes. +const int arena_size = 262144; +#else +const int arena_size = 32768; +#endif +#endif + +struct object +{ + size_t size __attribute__((aligned)); +}; + +static char arena[arena_size] __attribute__((aligned)); +static size_t pos; + +// So we can force a failure when needed. +static int fail; + +extern "C" void *malloc (size_t size) +{ + object *p = reinterpret_cast(&arena[pos]); + + if (fail) + return 0; + + p->size = size; + size = (size + __alignof__(object) - 1) & - __alignof__(object); + pos += size + sizeof(object); + + // Verify that we didn't run out of memory before getting initialized. + if (pos > arena_size) + abort (); + + return p + 1; +} + +extern "C" void free (void *) +{ +} + +extern "C" void *realloc (void *p, size_t size) +{ + void *r; + + if (p) + { + object *o = reinterpret_cast(p) - 1; + size_t old_size = o->size; + + if (old_size >= size) + { + r = p; + o->size = size; + } + else + { + r = malloc (size); + memcpy (r, p, old_size); + free (p); + } + } + else + r = malloc (size); + + return r; +} + +void fn_throw() throw(int) +{ + throw 1; +} + +void fn_rethrow() throw(int) +{ + try{fn_throw();} + catch(int a){ + throw;} +} + +void fn_catchthrow() throw(int) +{ + try{fn_throw();} + catch(int a){ + throw a + 1;} +} + +int main() +{ + /* On some systems (including FreeBSD and Solaris 2.10), + __cxa_get_globals will try to call "malloc" when threads are in + use. Therefore, we throw one exception up front so that + __cxa_get_globals is all set up. Ideally, this would not be + necessary, but it is a well-known idiom, and using this technique + means that we can still validate the fact that exceptions can be + thrown when malloc fails. */ + try{fn_throw();} + catch(int a){} + + fail = 1; + + try{fn_throw();} + catch(int a){} + + try{fn_rethrow();} + catch(int a){} + + try{fn_catchthrow();} + catch(int a){} + + return 0; +}
badalloc1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: vbase3.C =================================================================== --- vbase3.C (nonexistent) +++ vbase3.C (revision 338) @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Used to use -fsjlj-exceptions, but that isn't an option anymore. +// Origin: Donn Terry + +struct ios { + virtual ~ios(); +}; +struct fstreambase : virtual public ios { + fstreambase(); +}; +fstreambase::fstreambase() +{ +}
vbase3.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: crash3.C =================================================================== --- crash3.C (nonexistent) +++ crash3.C (revision 338) @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Origin: Marc Espie +// Used to use -fsjlj-exceptions, but that isn't an option anymore. + +extern double f(double a); + +void +a() +{ + double e; + double value; + + if (e == 0) + throw 1; + value = f(e); +}
crash3.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fntry1.C =================================================================== --- fntry1.C (nonexistent) +++ fntry1.C (revision 338) @@ -0,0 +1,32 @@ +// { dg-do run } +// Bug: g++ fails to treat function-try-blocks in ctors specially. +// Submitted by Jason Merrill + +int c; +int r; + +struct A { + int i; + A(int j) { i = j; } + ~A() { c += i; } +}; + +struct B: public A { + A a; + B() try : A(1), a(2) + { throw 1; } + catch (...) + { if (c != 3) r |= 1; } +}; + +int main () +{ + try + { B b; } + catch (...) + { c = 0; } + + if (c != 0) r |= 2; + + return r; +}
fntry1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch11.C =================================================================== --- catch11.C (nonexistent) +++ catch11.C (revision 338) @@ -0,0 +1,64 @@ +// { dg-do run } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 24 May 2000 + +// we should be able to catch a base a virtual, provided it is accessible by at +// least one public path +// -- public, << private, == virtual +// E<
catch11.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: throw2.C =================================================================== --- throw2.C (nonexistent) +++ throw2.C (revision 338) @@ -0,0 +1,16 @@ +// { dg-do assemble } + +// Submitted by Sebastian Ritterbusch + +#define ANY int // a class with a public constructor + +void athrow(const ANY & e) throw(ANY) +{ + throw e; // { dg-bogus "" } discarding const +} + +int main(void) +{ + athrow(ANY()); + return 0; +}
throw2.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: crash5.C =================================================================== --- crash5.C (nonexistent) +++ crash5.C (revision 338) @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Origin: Mark Mitchell + +int i; +int j; + +void +f () +{ + j = j + (i ? 7 : throw 1); +} +
crash5.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch13.C =================================================================== --- catch13.C (nonexistent) +++ catch13.C (revision 338) @@ -0,0 +1,19 @@ +// { dg-do assemble } +// { dg-options "-O2" } +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Jakub Jelinek 2 May 2001 + + +struct A; + +A *foo(); + +struct A { + A *a() { try { return foo(); } catch (...) {} } + void b(); + void c(); +}; + +void A::b() { + a()->c(); +}
catch13.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch5p.C =================================================================== --- catch5p.C (nonexistent) +++ catch5p.C (revision 338) @@ -0,0 +1,154 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// D--B==A +// +--C==A +// +--AA-A + + +struct A { int m; virtual ~A(){}}; +struct B : virtual A { int m; }; +struct C : virtual A { int m; }; +struct AA : A { int m; }; +struct D : B, C, AA { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } +void fnaa(AA *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(AA *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((AA *)d); } + catch(AA *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (AA *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)d); } + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with AA object + caught = 0; + try { fnaa((AA *)d); } + catch(A *p) { caught = 1; if (p != (AA *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnaa((AA *)d); } + catch(AA *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnaa((AA *)d); } + catch(C *p) { abort(); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +}
catch5p.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: flow1.C =================================================================== --- flow1.C (nonexistent) +++ flow1.C (revision 338) @@ -0,0 +1,23 @@ +// { dg-do run } +#include + +int bar () +{ + throw 100; + return 0; +} + +int main () +{ + int i = 0; // this gets deleted after flow analysis + try + { + i = bar (); + } + catch (...) + { + } + + printf ("i = %d\n", i); + return i; +}
flow1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: catch9p.C =================================================================== --- catch9p.C (nonexistent) +++ catch9p.C (revision 338) @@ -0,0 +1,117 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// D==B--A +// +==C--A + + +struct A { int m; virtual ~A(){}}; +struct B : A { int m; }; +struct C : A { int m; }; +struct D : virtual B, virtual C { int m; }; + + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)d); } + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +}
catch9p.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: tmpl1.C =================================================================== --- tmpl1.C (nonexistent) +++ tmpl1.C (revision 338) @@ -0,0 +1,16 @@ +// { dg-do run } +template +void f() throw (T) +{ + throw 7; +} + + +int main() +{ + try { + f(); + } catch (...) { + return 0; + } +}
tmpl1.C Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.