gcc/testsuite/gcc.c-torture/execute/20210505-1.c
raw| 1 | /* PR target/100402 */ |
| 2 | /* Testcase by Hannes Domani <[email protected]> */ |
| 3 | |
| 4 | /* { dg-require-effective-target indirect_jumps } */ |
| 5 | |
| 6 | #include <setjmp.h> |
| 7 | #include <stdbool.h> |
| 8 | |
| 9 | static jmp_buf buf; |
| 10 | static _Bool stop = false; |
| 11 | |
| 12 | void call_func (void(*func)(void)) |
| 13 | { |
| 14 | func (); |
| 15 | } |
| 16 | |
| 17 | void func (void) |
| 18 | { |
| 19 | stop = true; |
| 20 | longjmp (buf, 1); |
| 21 | } |
| 22 | |
| 23 | int main (void) |
| 24 | { |
| 25 | setjmp (buf); |
| 26 | |
| 27 | while (!stop) |
| 28 | call_func (func); |
| 29 | |
| 30 | return 0; |
| 31 | } |