aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr108117.c
blob: 4b3bebe229e579ad2c369f8d518af027dcfe1d38 (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
/* { dg-do run } */
/* { dg-require-effective-target nonlocal_goto } */
/* { dg-require-effective-target scheduling } */
/* { dg-options "-O2 -fschedule-insns" } */

#include <stdio.h>
#include <setjmp.h>

jmp_buf ex_buf;

__attribute__((noipa))
void fn_throw(int x)
{
   if (x)
      longjmp(ex_buf, 1);
}

int main(void)
{
    int vb = 0; // NB: not volatile, not modified after setjmp

    if (!setjmp(ex_buf)) {
        fn_throw(1);
        vb = 1; // not reached in the abstract machine
    }

    if (vb) {
        printf("Failed, vb = %d!\n", vb);
        return 1;
    }
}