| 1 |
/* Explicit { dg-require-effective-target exceptions_enabled } so that dependent tests don't turn UNRESOLVED for '-fno-exceptions'. */ |
| 2 |
/* { dg-options "-O" } */ |
| 3 |
|
| 4 |
int foo1(void) { return 0; } |
| 5 |
int bar1(void) { throw 1; } |
| 6 |
void foo2(void) { } |
| 7 |
void bar2(void) { throw 1; } |
| 8 |
void __attribute__((noinline,noclone)) test1(void (*f)(void)) { (*f)(); } |
| 9 |
void __attribute__((noinline,noclone)) test2(void (*f)(void)) { (*f)(); } |
| 10 |
int __attribute__((noinline,noclone)) test3(int (*f)(void)) { return (*f)(); } |
| 11 |
int __attribute__((noinline,noclone)) test4(int (*f)(void)) { return (*f)(); } |
| 12 |
int __attribute__((noinline,noclone)) test5(int (*f)(void), int x) { return x ? x : (*f)(); } |
| 13 |
int __attribute__((noinline,noclone)) test6(int (*f)(void), int x) { return x ? x : (*f)(); } |
| 14 |
void __attribute__((noinline,noclone)) test7(void (*f)(void)) { try { (*f)(); } catch (...) {} } |
| 15 |
void __attribute__((noinline,noclone)) test8(void (*f)(void)) { try { (*f)(); } catch (...) {}} |
| 16 |
int __attribute__((noinline,noclone)) test9(int (*f)(void)) { try { return (*f)(); } catch (...) {return 0;} } |
| 17 |
int __attribute__((noinline,noclone)) test10(int (*f)(void)) { try { return (*f)(); } catch (...) {return 0;} } |
| 18 |
int __attribute__((noinline,noclone)) test11(int (*f)(void), int x) { try { return x ? x : (*f)(); } catch (...) {return 0;} } |
| 19 |
int __attribute__((noinline,noclone)) test12(int (*f)(void), int x) { try { return x ? x : (*f)(); } catch (...) {return 0;} } |
| 20 |
|
| 21 |
int main() |
| 22 |
{ |
| 23 |
for (int i = 0; i < 100; ++i) test1(foo2); |
| 24 |
for (int i = 0; i < 100; ++i) try { test2(bar2); } catch (...) {} |
| 25 |
for (int i = 0; i < 100; ++i) test3(foo1); |
| 26 |
for (int i = 0; i < 100; ++i) try { test4(bar1); } catch (...) {} |
| 27 |
for (int i = 0; i < 100; ++i) test5(foo1, 0); |
| 28 |
for (int i = 0; i < 100; ++i) try { test6(bar1, 0); } catch (...) {} |
| 29 |
for (int i = 0; i < 100; ++i) test7(foo2); |
| 30 |
for (int i = 0; i < 100; ++i) try { test8(bar2); } catch (...) {} |
| 31 |
for (int i = 0; i < 100; ++i) test9(foo1); |
| 32 |
for (int i = 0; i < 100; ++i) try { test10(bar1); } catch (...) {} |
| 33 |
for (int i = 0; i < 100; ++i) test11(foo1, 0); |
| 34 |
for (int i = 0; i < 100; ++i) try { test12(bar1, 0); } catch (...) {} |
| 35 |
return 0; |
| 36 |
} |