lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | /* setjmp vs alloca test case. Exercised bug on sparc. */ |
| 2 | |
| 3 | #include <stdio.h> |
| 4 | #include <setjmp.h> |
| 5 | #include <alloca.h> |
| 6 | |
| 7 | int ret; |
| 8 | int verbose; |
| 9 | |
| 10 | __attribute__ ((__noreturn__)) |
| 11 | static void |
| 12 | sub5 (jmp_buf buf) |
| 13 | { |
| 14 | longjmp (buf, 1); |
| 15 | } |
| 16 | |
| 17 | static void |
| 18 | test (int x) |
| 19 | { |
| 20 | jmp_buf buf; |
| 21 | char *foo; |
| 22 | int arr[100]; |
| 23 | |
| 24 | ++ret; |
| 25 | |
| 26 | arr[77] = x; |
| 27 | if (setjmp (buf)) |
| 28 | { |
| 29 | --ret; |
| 30 | if (verbose) |
| 31 | printf ("made it ok; %d\n", arr[77]); |
| 32 | return; |
| 33 | } |
| 34 | |
| 35 | foo = (char *) alloca (128); |
| 36 | sub5 (buf); |
| 37 | } |
| 38 | |
| 39 | int |
| 40 | main (int argc, char *argv[]) |
| 41 | { |
| 42 | int i; |
| 43 | |
| 44 | verbose = (argc != 1); |
| 45 | ret = 0; |
| 46 | |
| 47 | for (i = 123; i < 345; ++i) |
| 48 | test (i); |
| 49 | |
| 50 | return ret; |
| 51 | } |