1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -emit-llvm -fcxx-exceptions -fexceptions -std=c++11 -o - | FileCheck %s 2*f4a2713aSLionel Sambuc struct A { virtual ~A(); }; 3*f4a2713aSLionel Sambuc struct B final : A { }; 4*f4a2713aSLionel Sambuc struct C { virtual ~C(); int c; }; 5*f4a2713aSLionel Sambuc 6*f4a2713aSLionel Sambuc // CHECK: @_Z1fP1B f(B * b)7*f4a2713aSLionel SambucC *f(B* b) { 8*f4a2713aSLionel Sambuc // CHECK-NOT: call i8* @__dynamic_cast 9*f4a2713aSLionel Sambuc // CHECK: ret %struct.C* null 10*f4a2713aSLionel Sambuc return dynamic_cast<C*>(b); 11*f4a2713aSLionel Sambuc } 12*f4a2713aSLionel Sambuc 13*f4a2713aSLionel Sambuc // CHECK: @_Z1fR1B f(B & b)14*f4a2713aSLionel SambucC &f(B& b) { 15*f4a2713aSLionel Sambuc // CHECK-NOT: call i8* @__dynamic_cast 16*f4a2713aSLionel Sambuc // CHECK: call void @__cxa_bad_cast() [[NR:#[0-9]+]] 17*f4a2713aSLionel Sambuc // CHECK: ret %struct.C* undef 18*f4a2713aSLionel Sambuc return dynamic_cast<C&>(b); 19*f4a2713aSLionel Sambuc } 20*f4a2713aSLionel Sambuc dont_crash()21*f4a2713aSLionel Sambucvoid dont_crash() { 22*f4a2713aSLionel Sambuc (void) dynamic_cast<void*>((A*)0); 23*f4a2713aSLionel Sambuc (void) dynamic_cast<void*>((B*)0); 24*f4a2713aSLionel Sambuc } 25*f4a2713aSLionel Sambuc 26*f4a2713aSLionel Sambuc // CHECK: attributes [[NR]] = { noreturn } 27