blob: 8470f9cbf884c8cc91a8a6e6449b2717ad1fd3b3 (
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
|
/* { dg-do compile } */
/* { dg-options "-O -fcf-protection" } */
/* { dg-final { scan-assembler-times "endbr32" 2 { target ia32 } } } */
/* { dg-final { scan-assembler-times "endbr64" 2 { target { ! ia32 } } } } */
/* { dg-final { scan-assembler-times "call _?setjmp" 1 } } */
/* { dg-final { scan-assembler-times "call _?longjmp" 1 } } */
#include <stdio.h>
#include <setjmp.h>
jmp_buf buf;
static int bar (int);
__attribute__ ((noinline, noclone))
static int
foo (int i)
{
int j = i * 11;
if (!setjmp (buf))
{
j += 33;
printf ("After setjmp: j = %d\n", j);
bar (j);
}
return j + i;
}
__attribute__ ((noinline, noclone))
static int
bar (int i)
{
int j = i;
j -= 111;
printf ("In longjmp: j = %d\n", j);
longjmp (buf, 1);
return j;
}
int
main ()
{
foo (10);
return 0;
}
|