1// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm < %s| FileCheck %s
2// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm < %s| FileCheck %s
3// RUN: %clang_cc1 -triple x86_64-windows -emit-llvm < %s| FileCheck %s
4// RUN: %clang_cc1 -triple powerpc-unknown-unknown -emit-llvm < %s| FileCheck %s
5// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm < %s| FileCheck %s
6
7// RUN: %clang_cc1 -triple arm-unknown-unknown -emit-llvm-only -verify %s
8// RUN: %clang_cc1 -triple aarch64-unknown-unknown -emit-llvm-only -verify %s
9// RUN: %clang_cc1 -triple mips-unknown-unknown -emit-llvm-only -verify %s
10// RUN: %clang_cc1 -triple mips64-unknown-unknown -emit-llvm-only -verify %s
11
12// Check that __builtin_longjmp and __builtin_setjmp are lowered into
13// IR intrinsics on those architectures that can handle them.
14// Check that an error is created otherwise.
15
16typedef void *jmp_buf;
17jmp_buf buf;
18
19// CHECK:   define{{.*}} void @do_jump()
20// CHECK:   call{{.*}} void @llvm.eh.sjlj.longjmp
21
22// CHECK:   define{{.*}} void @do_setjmp()
23// CHECK:   call{{.*}} i32 @llvm.eh.sjlj.setjmp
24
25void do_jump(void) {
26  __builtin_longjmp(buf, 1); // expected-error {{__builtin_longjmp is not supported for the current target}}
27}
28
29void f(void);
30
31void do_setjmp(void) {
32  if (!__builtin_setjmp(buf)) // expected-error {{__builtin_setjmp is not supported for the current target}}
33    f();
34}
35