James Y Knight fddc4e4116 Correct handling of the 'throw()' exception specifier in C++17.
Per C++17 [except.spec], 'throw()' has become equivalent to
'noexcept', and should therefore call std::terminate, not
std::unexpected.

Differential Revision: https://reviews.llvm.org/D113517
2021-11-10 17:40:16 -05:00

27 lines
973 B
C++

// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s --check-prefixes=CHECK,CHECK-PRE17
// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -std=c++17 -Wno-dynamic-exception-spec -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s --check-prefixes=CHECK,CHECK-17
void external();
// CHECK-LABEL: _Z6targetv(
// CHECK: invoke void @_Z8externalv()
// CHECK: landingpad { i8*, i32 }
// CHECK-NEXT: filter [1 x i8*] [i8* bitcast (i8** @_ZTIi to i8*)]
// CHECK: call void @__cxa_call_unexpected
void target() throw(int)
{
external();
}
// CHECK-LABEL: _Z7target2v(
// CHECK: invoke void @_Z8externalv()
// CHECK: landingpad { i8*, i32 }
// CHECK-PRE17-NEXT: filter [0 x i8*] zeroinitializer
// CHECK-17-NEXT: catch i8* null
// CHECK-PRE17: call void @__cxa_call_unexpected
// CHECK-17: call void @__clang_call_terminate
void target2() throw()
{
external();
}