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

#include <testfwk.h>

#ifdef __SDCC
#pragma std_c99
#endif

#if !defined(__SDCC_pic14) // Unimplemented setjmp
#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;
    }
}
#endif

void
testTortureExecute (void)
{
#if !defined(__SDCC_pic14) // Unimplemented setjmp
  if (foo (1) == 0)
    ASSERT (0);
#endif
}