Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / cet-sjlj-5.c
blob1b624327d0f4684de59c76935cad193e58ae6821
1 /* { dg-do compile } */
2 /* { dg-options "-O -fcf-protection" } */
3 /* { dg-final { scan-assembler-times "endbr32" 2 { target ia32 } } } */
4 /* { dg-final { scan-assembler-times "endbr64" 2 { target { ! ia32 } } } } */
5 /* { dg-final { scan-assembler-times "call _?setjmp" 1 } } */
6 /* { dg-final { scan-assembler-times "call longjmp" 1 } } */
8 #include <stdio.h>
9 #include <setjmp.h>
11 jmp_buf buf;
12 static int bar (int);
14 __attribute__ ((noinline, noclone))
15 static int
16 foo (int i)
18 int j = i * 11;
20 if (!setjmp (buf))
22 j += 33;
23 printf ("After setjmp: j = %d\n", j);
24 bar (j);
27 return j + i;
30 __attribute__ ((noinline, noclone))
31 static int
32 bar (int i)
34 int j = i;
36 j -= 111;
37 printf ("In longjmp: j = %d\n", j);
38 longjmp (buf, 1);
40 return j;
43 int
44 main ()
46 foo (10);
47 return 0;