aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr116906-2.c
blob: 4172ec3644a8c0ceb12691c9f4c68020b95298a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* { dg-do run } */
/* { dg-require-effective-target alarm } */
/* { dg-require-effective-target signal } */
/* { dg-options "-O2 -fno-tree-ch" } */

#include <unistd.h>
#include <signal.h>
#include <stdlib.h>

int x;

void __attribute__((noipa))
foo (int *p, unsigned n)
{
  unsigned i = 0;
  do
    {
      if (i == n)
        break;
      if (p)
        x = *p;
      i += 2;
    }
  while (1);
  x = *p;
}

void do_exit (int i)
{
  exit (0);
}

int main()
{
  struct sigaction s;
  sigemptyset (&s.sa_mask);
  s.sa_handler = do_exit;
  s.sa_flags = 0;
  sigaction (SIGALRM, &s, NULL);
  alarm (1);
  foo ((int *)0, 1);
}