// Tests that the exceptions declared by the TM TS (N4514) as transaction_safe // are indeed that. Thus, this also tests the transactional clones in // libstdc++ and libsupc++. // Not supported on Darwin nor AIX because those lack the support for // weak references to undefined functions that we need in libstdc++ to make // exceptions transaction-safe. // { dg-do run { target { ! { *-*-darwin* powerpc-ibm-aix* } } } } #include #include #include #include using namespace std; template void thrower(const T& t) { try { atomic_commit { throw t; } } catch (T ex) { if (ex != t) abort (); } } template void thrower1(const string& what) { try { atomic_commit { throw T (); } } catch (T ex) { if (what != ex.what()) abort (); } } template void thrower2(const string& what) { try { atomic_commit { throw T (what); } } catch (T ex) { if (what != ex.what()) abort (); } } int main () { thrower (23); thrower (23); thrower (23); thrower (23); thrower (23); thrower (23); thrower (42); thrower (42); thrower (42); thrower (42); thrower (23.42); thrower (23.42); thrower (23.42); thrower (0); thrower (0); thrower1 ("std::exception"); thrower1 ("std::bad_exception"); thrower2 ("test"); thrower2 ("test"); thrower2 ("test"); thrower2 ("test"); thrower2 ("test"); thrower2 ("test"); thrower2 ("test"); thrower2 ("test"); thrower2 ("test"); return 0; }