1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -Wno-unreachable-code -Werror -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc int val = 42; 4*f4a2713aSLionel Sambuc int& test1() { 5*f4a2713aSLionel Sambuc return throw val, val; 6*f4a2713aSLionel Sambuc } 7*f4a2713aSLionel Sambuc 8*f4a2713aSLionel Sambuc int test2() { 9*f4a2713aSLionel Sambuc return val ? throw val : val; 10*f4a2713aSLionel Sambuc } 11*f4a2713aSLionel Sambuc 12*f4a2713aSLionel Sambuc // rdar://problem/8608801 13*f4a2713aSLionel Sambuc void test3() { 14*f4a2713aSLionel Sambuc throw false; 15*f4a2713aSLionel Sambuc } 16*f4a2713aSLionel Sambuc 17*f4a2713aSLionel Sambuc // PR10582 18*f4a2713aSLionel Sambuc int test4() { 19*f4a2713aSLionel Sambuc return 1 ? throw val : val; 20*f4a2713aSLionel Sambuc } 21*f4a2713aSLionel Sambuc 22*f4a2713aSLionel Sambuc // PR15923 23*f4a2713aSLionel Sambuc int test5(bool x, bool y, int z) { 24*f4a2713aSLionel Sambuc return (x ? throw 1 : y) ? z : throw 2; 25*f4a2713aSLionel Sambuc } 26*f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z5test5bbi( 27*f4a2713aSLionel Sambuc // CHECK: br i1 28*f4a2713aSLionel Sambuc // 29*f4a2713aSLionel Sambuc // x.true: 30*f4a2713aSLionel Sambuc // CHECK: call void @__cxa_throw( 31*f4a2713aSLionel Sambuc // CHECK-NEXT: unreachable 32*f4a2713aSLionel Sambuc // 33*f4a2713aSLionel Sambuc // x.false: 34*f4a2713aSLionel Sambuc // CHECK: br i1 35*f4a2713aSLionel Sambuc // 36*f4a2713aSLionel Sambuc // y.true: 37*f4a2713aSLionel Sambuc // CHECK: load i32* 38*f4a2713aSLionel Sambuc // CHECK: br label 39*f4a2713aSLionel Sambuc // 40*f4a2713aSLionel Sambuc // y.false: 41*f4a2713aSLionel Sambuc // CHECK: call void @__cxa_throw( 42*f4a2713aSLionel Sambuc // CHECK-NEXT: unreachable 43*f4a2713aSLionel Sambuc // 44*f4a2713aSLionel Sambuc // end: 45*f4a2713aSLionel Sambuc // CHECK: ret i32 46*f4a2713aSLionel Sambuc 47*f4a2713aSLionel Sambuc int test6(bool x, bool y, int z) { 48*f4a2713aSLionel Sambuc return (x ? throw 1 : y) ? z : (throw 2); 49*f4a2713aSLionel Sambuc } 50*f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z5test6bbi( 51*f4a2713aSLionel Sambuc // CHECK: br i1 52*f4a2713aSLionel Sambuc // 53*f4a2713aSLionel Sambuc // x.true: 54*f4a2713aSLionel Sambuc // CHECK: call void @__cxa_throw( 55*f4a2713aSLionel Sambuc // CHECK-NEXT: unreachable 56*f4a2713aSLionel Sambuc // 57*f4a2713aSLionel Sambuc // x.false: 58*f4a2713aSLionel Sambuc // CHECK: br i1 59*f4a2713aSLionel Sambuc // 60*f4a2713aSLionel Sambuc // y.true: 61*f4a2713aSLionel Sambuc // CHECK: load i32* 62*f4a2713aSLionel Sambuc // CHECK: br label 63*f4a2713aSLionel Sambuc // 64*f4a2713aSLionel Sambuc // y.false: 65*f4a2713aSLionel Sambuc // CHECK: call void @__cxa_throw( 66*f4a2713aSLionel Sambuc // CHECK-NEXT: unreachable 67*f4a2713aSLionel Sambuc // 68*f4a2713aSLionel Sambuc // end: 69*f4a2713aSLionel Sambuc // CHECK: ret i32 70