1 //===-- main.c --------------------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 #include <setjmp.h> 9 #include <stdio.h> 10 #include <time.h> 11 12 jmp_buf j; 13 14 void do_jump(void) 15 { 16 // We can't let the compiler know this will always happen or it might make 17 // optimizations that break our test. 18 if (!clock()) 19 longjmp(j, 1); // non-local goto 20 } 21 22 int main (void) 23 { 24 if (setjmp(j) == 0) 25 do_jump(); 26 else 27 return 0; // destination of longjmp 28 29 return 1; 30 } 31