aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/20210505-1.c
blob: 10a2de07921b7a919ea652ddb82c8ef760d91f26 (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
/* PR target/100402 */
/* Testcase by Hannes Domani <ssbssa@yahoo.de> */

/* { dg-require-effective-target indirect_jumps } */

#include <setjmp.h>
#include <stdbool.h>

static jmp_buf buf;
static _Bool stop = false;

void call_func (void(*func)(void))
{
  func ();
}

void func (void)
{
  stop = true;
  longjmp (buf, 1);
}

int main (void)
{
  setjmp (buf);

  while (!stop)
    call_func (func);

  return 0;
}