summaryrefslogtreecommitdiff
path: root/support/regression/tests/gcc-torture-execute-pr60003.c
blob: 6caf875568054248ca0d374f1372effd68ff9f39 (plain) (blame)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
   pr60003.c from the execute part of the gcc torture tests.
 */

#include <testfwk.h>

#ifdef __SDCC
#pragma std_c99
#endif

#include <setjmp.h>

/* PR tree-optimization/60003 */
/* { dg-require-effective-target indirect_jumps } */

jmp_buf buf;

void
baz (void)
{
  longjmp (buf, 1);
}

void
bar (void)
{
  baz ();
}

int
foo (int x)
{
  volatile int a = 0;

  if (setjmp (buf) == 0)
    {
      while (1)
	{
	  a = 1;
	  bar ();  /* OK if baz () instead */
	}
    }
  else
    {
      if (a == 0)
	return 0;
      else
	return x;
    }
}

void
testTortureExecute (void)
{
  if (foo (1) == 0)
    ASSERT (0);
}