Debian Codegraph @

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

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O -fcf-protection" } */
3 /* { dg-final { scan-assembler-times "endbr32" 4 { target ia32 } } } */
4 /* { dg-final { scan-assembler-times "endbr64" 4 { 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 raise0(void)
15 {
16 __builtin_longjmp (buf, 1);
17 }
18
19 int execute(int cmd)
20 {
21 int last = 0;
22
23 if (__builtin_setjmp (buf) == 0)
24 while (1)
25 {
26 last = 1;
27 raise0 ();
28 }
29
30 if (last == 0)
31 return 0;
32 else
33 return cmd;
34 }
35
36 int main(void)
37 {
38 if (execute (1) == 0)
39 abort ();
40
41 return 0;
42 }