Debian Codegraph @

gcc/testsuite/gcc.target/i386/cet-sjlj-4.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O -fcf-protection" } */
3 /* { dg-final { scan-assembler-times "endbr32" 3 { target ia32 } } } */
4 /* { dg-final { scan-assembler-times "endbr64" 3 { target { ! ia32 } } } } */
5 /* { dg-final { scan-assembler-times "rdssp\[dq]" 2 } } */
6 /* { dg-final { scan-assembler-times "incssp\[dq]" 2 } } */
7
8 /* Based on gcc.dg/setjmp-3.c. */
9
10 void *buf[5];
11
12 extern void abort (void);
13
14 void
15 raise0 (void)
16 {
17 __builtin_longjmp (buf, 1);
18 }
19
20 __attribute__ ((noinline, noclone))
21 static int
22 execute (int cmd)
23 {
24 int last = 0;
25
26 if (__builtin_setjmp (buf) == 0)
27 while (1)
28 {
29 last = 1;
30 raise0 ();
31 }
32
33 if (last == 0)
34 return 0;
35 else
36 return cmd;
37 }
38
39 int main(void)
40 {
41 if (execute (1) == 0)
42 abort ();
43
44 return 0;
45 }