[ELF] MergeInputSection: replace Fatal with Err
[llvm-project.git] / clang / test / CodeGen / attr-noreturn.c
blobc3f41d8424bed6a5add8be1b5eeb07443f5b6bd1
1 // RUN: %clang_cc1 -Wno-error=return-type -emit-llvm -std=c2x %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -Wno-error=return-type -triple %itanium_abi_triple -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CXX
4 typedef void (*fptrs_t[4])(void);
5 fptrs_t p __attribute__((noreturn));
7 void __attribute__((noreturn)) f(void) {
8 p[0]();
10 // CHECK: call void
11 // CHECK-NEXT: unreachable
13 // CHECK-LABEL: @test_conditional_gnu(
14 // CHECK: %cond = select i1 %tobool, ptr @t1, ptr @t2
15 // CHECK: call void %cond(
16 // CHECK: call void %cond2(
17 // CHECK-NEXT: unreachable
19 // CHECK-CXX-LABEL: @_Z20test_conditional_gnui(
20 // CHECK-CXX: %cond{{.*}} = phi ptr [ @_Z2t1i, %{{.*}} ], [ @_Z2t2i, %{{.*}} ]
21 // CHECK-CXX: call void %cond{{.*}}(
22 // CHECK-CXX: %cond{{.*}} = phi ptr [ @_Z2t1i, %{{.*}} ], [ @_Z2t1i, %{{.*}} ]
23 // CHECK-CXX: call void %cond{{.*}}(
24 // CHECK-CXX-NEXT: unreachable
25 void t1(int) __attribute__((noreturn));
26 void t2(int);
27 __attribute__((noreturn)) void test_conditional_gnu(int a) {
28 // The conditional operator isn't noreturn because t2 isn't.
29 (a ? t1 : t2)(a);
30 // The conditional operator is noreturn.
31 (a ? t1 : t1)(a);
34 // CHECK-LABEL: @test_conditional_Noreturn(
35 // CHECK: %cond = select i1 %tobool, ptr @t3, ptr @t2
36 // CHECK: call void %cond(
37 // CHECK: %cond2 = select i1 %tobool1, ptr @t3, ptr @t3
38 // CHECK: call void %cond2(
39 // CHECK-NEXT: ret void
40 _Noreturn void t3(int);
41 _Noreturn void test_conditional_Noreturn(int a) {
42 (a ? t3 : t2)(a);
43 (a ? t3 : t3)(a);
46 // CHECK-LABEL: @test_conditional_std(
47 // CHECK: %cond = select i1 %tobool, ptr @t4, ptr @t2
48 // CHECK: call void %cond(
49 // CHECK: %cond2 = select i1 %tobool1, ptr @t4, ptr @t4
50 // CHECK: call void %cond2(
51 // CHECK-NEXT: ret void
52 [[noreturn]] void t4(int);
53 [[noreturn]] void test_conditional_std(int a) {
54 (a ? t4 : t2)(a);
55 (a ? t4 : t4)(a);