(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
i386/
cet-sjlj-3.c
       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 "call	_?setjmp" 1 } } */
       6  /* { dg-final { scan-assembler-times "call	_?longjmp" 1 } } */
       7  
       8  #include <stdio.h>
       9  #include <setjmp.h>
      10  
      11  jmp_buf buf;
      12  int bar (int);
      13  
      14  int
      15  foo (int i)
      16  {
      17    int j = i * 11;
      18  
      19    if (!setjmp (buf))
      20      {
      21        j += 33;
      22        printf ("After setjmp: j = %d\n", j);
      23        bar (j);
      24      }
      25  
      26    return j + i;
      27  }
      28  
      29  int
      30  bar (int i)
      31  {
      32  int j = i;
      33  
      34    j -= 111;
      35    printf ("In longjmp: j = %d\n", j);
      36    longjmp (buf, 1);
      37  
      38    return j;
      39  }
      40  
      41  int
      42  main ()
      43  {
      44    foo (10);
      45    return 0;
      46  }