1 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -Wno-unreachable-code -Werror -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
9 return val
? throw val
: val
;
18 return 1 ? throw val
: val
;
22 int test5(bool x
, bool y
, int z
) {
23 return (x
? throw 1 : y
) ? z
: throw 2;
25 // CHECK-LABEL: define{{.*}} i32 @_Z5test5bbi(
29 // CHECK: call void @__cxa_throw(
30 // CHECK-NEXT: unreachable
36 // CHECK: load i32, ptr
40 // CHECK: call void @__cxa_throw(
41 // CHECK-NEXT: unreachable
46 int test6(bool x
, bool y
, int z
) {
47 return (x
? throw 1 : y
) ? z
: (throw 2);
49 // CHECK-LABEL: define{{.*}} i32 @_Z5test6bbi(
53 // CHECK: call void @__cxa_throw(
54 // CHECK-NEXT: unreachable
60 // CHECK: load i32, ptr
64 // CHECK: call void @__cxa_throw(
65 // CHECK-NEXT: unreachable
76 // CHECK-LABEL: @_ZN6DR15601bE
77 const A
&r
= b
? get() : throw 0;
78 // CHECK-NOT: call {{.*}}@_ZN6DR15601AD1Ev
79 // CHECK: call {{.*}} @__cxa_atexit(ptr @_ZN6DR15601AD1Ev, ptr @_ZGRN6DR15601rE
80 // CHECK-NOT: call {{.*}}@_ZN6DR15601AD1Ev
83 void conditional_throw() {
85 (true ? throw 0 : a
) = 0; // CHECK: call void @__cxa_throw({{.*}})
89 // CHECK-LABEL: define{{.*}} void @_Z5test7b(
90 void test7(bool cond
) {
94 // CHECK: call void @__cxa_throw(
95 // CHECK-NEXT: unreachable
102 cond
? throw test7
: val
;
105 // CHECK-LABEL: define{{.*}} nonnull align 4 dereferenceable(4) ptr @_Z5test8b(
106 int &test8(bool cond
) {
113 // CHECK: call void @__cxa_throw(
114 // CHECK-NEXT: unreachable
117 // CHECK: ret ptr @val
118 return cond
? val
: ((throw "foo"));