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