| 1 |
/* { dg-require-effective-target alarm } */ |
| 2 |
/* { dg-require-effective-target signal } */ |
| 3 |
/* { dg-options "-O2 -fno-tree-ch" } */ |
| 4 |
|
| 5 |
#include <unistd.h> |
| 6 |
#include <signal.h> |
| 7 |
#include <stdlib.h> |
| 8 |
|
| 9 |
int x; |
| 10 |
|
| 11 |
void __attribute__((noipa)) |
| 12 |
foo (int *p, unsigned n) |
| 13 |
{ |
| 14 |
unsigned i = 0; |
| 15 |
do |
| 16 |
{ |
| 17 |
if (i == n) |
| 18 |
break; |
| 19 |
if (p) |
| 20 |
x = *p; |
| 21 |
i += 2; |
| 22 |
} |
| 23 |
while (1); |
| 24 |
x = *p; |
| 25 |
} |
| 26 |
|
| 27 |
void do_exit (int i) |
| 28 |
{ |
| 29 |
exit (0); |
| 30 |
} |
| 31 |
|
| 32 |
int main() |
| 33 |
{ |
| 34 |
struct sigaction s; |
| 35 |
sigemptyset (&s.sa_mask); |
| 36 |
s.sa_handler = do_exit; |
| 37 |
s.sa_flags = 0; |
| 38 |
sigaction (SIGALRM, &s, NULL); |
| 39 |
alarm (1); |
| 40 |
foo ((int *)0, 1); |
| 41 |
} |