Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@@ -0,0 +1,55 @@
include(AddLLVM) # for add_lit_testsuite
macro(pythonize_bool var)
if (${var})
set(${var} True)
else()
set(${var} False)
endif()
endmacro()
if (NOT DEFINED LIBCXX_ENABLE_SHARED)
set(LIBCXX_ENABLE_SHARED ON)
endif()
pythonize_bool(LIBCXXABI_BUILD_32_BITS)
pythonize_bool(LIBCXX_ENABLE_SHARED)
pythonize_bool(LIBCXXABI_ENABLE_SHARED)
pythonize_bool(LIBCXXABI_ENABLE_THREADS)
pythonize_bool(LIBCXXABI_ENABLE_EXCEPTIONS)
pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
pythonize_bool(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
set(LIBCXXABI_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
"TargetInfo to use when setting up test environment.")
set(LIBCXXABI_EXECUTOR "None" CACHE STRING
"Executor to use when running tests.")
set(AUTO_GEN_COMMENT "## Autogenerated by libcxxabi configuration.\n# Do not edit!")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
@ONLY)
if (LIBCXXABI_ENABLE_SHARED)
set(LIBCXXABI_TEST_DEPS cxxabi_shared)
else()
set(LIBCXXABI_TEST_DEPS cxxabi_static)
endif()
if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
list(APPEND LIBCXXABI_TEST_DEPS cxx_external_threads)
endif()
if (NOT LIBCXXABI_STANDALONE_BUILD)
list(APPEND LIBCXXABI_TEST_DEPS cxx)
if (LIBCXXABI_USE_LLVM_UNWINDER)
list(APPEND LIBCXXABI_TEST_DEPS unwind)
endif()
endif()
add_lit_testsuite(check-cxxabi "Running libcxxabi tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${LIBCXXABI_TEST_DEPS}
)
# TODO: This is a legacy target name and should be removed at some point.
add_custom_target(check-libcxxabi DEPENDS check-cxxabi)

View File

@@ -0,0 +1,69 @@
//===---------------------- backtrace_test.cpp ----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: libcxxabi-no-exceptions
#include <assert.h>
#include <stddef.h>
#include <unwind.h>
extern "C" _Unwind_Reason_Code
trace_function(struct _Unwind_Context*, void* ntraced) {
(*reinterpret_cast<size_t*>(ntraced))++;
// We should never have a call stack this deep...
assert(*reinterpret_cast<size_t*>(ntraced) < 20);
return _URC_NO_REASON;
}
__attribute__ ((__noinline__))
void call3_throw(size_t* ntraced) {
try {
_Unwind_Backtrace(trace_function, ntraced);
} catch (...) {
assert(false);
}
}
__attribute__ ((__noinline__, __disable_tail_calls__))
void call3_nothrow(size_t* ntraced) {
_Unwind_Backtrace(trace_function, ntraced);
}
__attribute__ ((__noinline__, __disable_tail_calls__))
void call2(size_t* ntraced, bool do_throw) {
if (do_throw) {
call3_throw(ntraced);
} else {
call3_nothrow(ntraced);
}
}
__attribute__ ((__noinline__, __disable_tail_calls__))
void call1(size_t* ntraced, bool do_throw) {
call2(ntraced, do_throw);
}
int main() {
size_t throw_ntraced = 0;
size_t nothrow_ntraced = 0;
call1(&nothrow_ntraced, false);
try {
call1(&throw_ntraced, true);
} catch (...) {
assert(false);
}
// Different platforms (and different runtimes) will unwind a different number
// of times, so we can't make any better assumptions than this.
assert(nothrow_ntraced > 1);
assert(throw_ntraced == nothrow_ntraced); // Make sure we unwind through catch
return 0;
}

View File

@@ -0,0 +1,35 @@
//===---------------------- catch_array_01.cpp ----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// Can you have a catch clause of array type that catches anything?
// GCC incorrectly allows array types to be caught by reference.
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69372
// XFAIL: gcc
// UNSUPPORTED: libcxxabi-no-exceptions
#include <cassert>
int main()
{
typedef char Array[4];
Array a = {'H', 'i', '!', 0};
try
{
throw a; // converts to char*
assert(false);
}
catch (Array& b) // can't catch char*
{
assert(false);
}
catch (...)
{
}
}

View File

@@ -0,0 +1,31 @@
//===---------------------- catch_array_02.cpp ----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// Can you have a catch clause of array type that catches anything?
// UNSUPPORTED: libcxxabi-no-exceptions
#include <cassert>
int main()
{
typedef char Array[4];
Array a = {'H', 'i', '!', 0};
try
{
throw a; // converts to char*
assert(false);
}
catch (Array b) // equivalent to char*
{
}
catch (...)
{
assert(false);
}
}

View File

@@ -0,0 +1,60 @@
//===---------------------- catch_class_01.cpp ----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: libcxxabi-no-exceptions
#include <exception>
#include <stdlib.h>
#include <assert.h>
struct A
{
static int count;
int id_;
explicit A(int id) : id_(id) {count++;}
A(const A& a) : id_(a.id_) {count++;}
~A() {count--;}
};
int A::count = 0;
void f1()
{
throw A(3);
}
void f2()
{
try
{
assert(A::count == 0);
f1();
}
catch (A a)
{
assert(A::count != 0);
assert(a.id_ == 3);
throw;
}
}
int main()
{
try
{
f2();
assert(false);
}
catch (const A& a)
{
assert(A::count != 0);
assert(a.id_ == 3);
}
assert(A::count == 0);
}

View File

@@ -0,0 +1,85 @@
//===---------------------- catch_class_02.cpp ----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: libcxxabi-no-exceptions
#include <exception>
#include <stdlib.h>
#include <assert.h>
struct B
{
static int count;
int id_;
explicit B(int id) : id_(id) {count++;}
B(const B& a) : id_(a.id_) {count++;}
~B() {count--;}
};
int B::count = 0;
struct A
: B
{
static int count;
int id_;
explicit A(int id) : B(id-1), id_(id) {count++;}
A(const A& a) : B(a.id_-1), id_(a.id_) {count++;}
~A() {count--;}
};
int A::count = 0;
void f1()
{
assert(A::count == 0);
assert(B::count == 0);
A a(3);
assert(A::count == 1);
assert(B::count == 1);
throw a;
assert(false);
}
void f2()
{
try
{
assert(A::count == 0);
f1();
assert(false);
}
catch (A a)
{
assert(A::count != 0);
assert(B::count != 0);
assert(a.id_ == 3);
throw;
}
catch (B b)
{
assert(false);
}
}
int main()
{
try
{
f2();
assert(false);
}
catch (const B& b)
{
assert(B::count != 0);
assert(b.id_ == 2);
}
assert(A::count == 0);
assert(B::count == 0);
}

View File

@@ -0,0 +1,199 @@
//===---------------------- catch_class_03.cpp ----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
This test checks that adjustedPtr is correct as there exist offsets in this
object for the various subobjects, all of which have a unique id_ to
check against.
*/
// UNSUPPORTED: libcxxabi-no-exceptions
#include <exception>
#include <stdlib.h>
#include <assert.h>
// Clang emits warnings about exceptions of type 'Child' being caught by
// an earlier handler of type 'Base'. Congrats clang, you've just
// diagnosed the behavior under test.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wexceptions"
#endif
struct B
{
static int count;
int id_;
explicit B(int id) : id_(id) {count++;}
B(const B& a) : id_(a.id_) {count++;}
~B() {count--;}
};
int B::count = 0;
struct C1
: B
{
static int count;
int id_;
explicit C1(int id) : B(id-2), id_(id) {count++;}
C1(const C1& a) : B(a.id_-2), id_(a.id_) {count++;}
~C1() {count--;}
};
int C1::count = 0;
struct C2
: B
{
static int count;
int id_;
explicit C2(int id) : B(id-2), id_(id) {count++;}
C2(const C2& a) : B(a.id_-2), id_(a.id_) {count++;}
~C2() {count--;}
};
int C2::count = 0;
struct A
: C1, C2
{
static int count;
int id_;
explicit A(int id) : C1(id-1), C2(id-2), id_(id) {count++;}
A(const A& a) : C1(a.id_-1), C2(a.id_-2), id_(a.id_) {count++;}
~A() {count--;}
};
int A::count = 0;
void f1()
{
assert(A::count == 0);
assert(C1::count == 0);
assert(C2::count == 0);
assert(B::count == 0);
A a(5);
assert(A::count == 1);
assert(C1::count == 1);
assert(C2::count == 1);
assert(B::count == 2);
assert(a.id_ == 5);
assert(static_cast<C1&>(a).id_ == 4);
assert(static_cast<C2&>(a).id_ == 3);
assert(static_cast<B&>(static_cast<C1&>(a)).id_ == 2);
assert(static_cast<B&>(static_cast<C2&>(a)).id_ == 1);
throw a;
assert(false);
}
void f2()
{
try
{
assert(A::count == 0);
assert(C1::count == 0);
assert(C2::count == 0);
assert(B::count == 0);
f1();
assert(false);
}
catch (const A& a) // can catch A
{
assert(a.id_ == 5);
assert(static_cast<const C1&>(a).id_ == 4);
assert(static_cast<const C2&>(a).id_ == 3);
assert(static_cast<const B&>(static_cast<const C1&>(a)).id_ == 2);
assert(static_cast<const B&>(static_cast<const C2&>(a)).id_ == 1);
throw;
}
catch (const C1&)
{
assert(false);
}
catch (const C2&)
{
assert(false);
}
catch (const B&)
{
assert(false);
}
}
void f3()
{
try
{
assert(A::count == 0);
assert(C1::count == 0);
assert(C2::count == 0);
assert(B::count == 0);
f2();
assert(false);
}
catch (const B& a) // can not catch B (ambiguous base)
{
assert(false);
}
catch (const C1& c1) // can catch C1
{
assert(c1.id_ == 4);
assert(static_cast<const B&>(c1).id_ == 2);
throw;
}
catch (const C2&)
{
assert(false);
}
}
void f4()
{
try
{
assert(A::count == 0);
assert(C1::count == 0);
assert(C2::count == 0);
assert(B::count == 0);
f3();
assert(false);
}
catch (const B& a) // can not catch B (ambiguous base)
{
assert(false);
}
catch (const C2& c2) // can catch C2
{
assert(c2.id_ == 3);
assert(static_cast<const B&>(c2).id_ == 1);
throw;
}
catch (const C1&)
{
assert(false);
}
}
int main()
{
try
{
f4();
assert(false);
}
catch (...)
{
}
assert(A::count == 0);
assert(C1::count == 0);
assert(C2::count == 0);
assert(B::count == 0);
}

View File

@@ -0,0 +1,222 @@
//===---------------------- catch_class_04.cpp ----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
This test checks that adjustedPtr is correct as there exist offsets in this
object for the various subobjects, all of which have a unique id_ to
check against. It also checks that virtual bases work properly
*/
// UNSUPPORTED: libcxxabi-no-exceptions
#include <exception>
#include <stdlib.h>
#include <assert.h>
// Clang emits warnings about exceptions of type 'Child' being caught by
// an earlier handler of type 'Base'. Congrats clang, you've just
// diagnosed the behavior under test.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wexceptions"
#endif
struct B
{
static int count;
int id_;
explicit B(int id) : id_(id) {count++;}
B(const B& a) : id_(a.id_) {count++;}
~B() {count--;}
};
int B::count = 0;
struct C1
: virtual B
{
static int count;
int id_;
explicit C1(int id) : B(id-2), id_(id) {count++;}
C1(const C1& a) : B(a.id_-2), id_(a.id_) {count++;}
~C1() {count--;}
};
int C1::count = 0;
struct C2
: virtual private B
{
static int count;
int id_;
explicit C2(int id) : B(id-2), id_(id) {count++;}
C2(const C2& a) : B(a.id_-2), id_(a.id_) {count++;}
~C2() {count--;}
};
int C2::count = 0;
struct A
: C1, C2
{
static int count;
int id_;
explicit A(int id) : B(id+3), C1(id-1), C2(id-2), id_(id) {count++;}
A(const A& a) : B(a.id_+3), C1(a.id_-1), C2(a.id_-2), id_(a.id_) {count++;}
~A() {count--;}
};
int A::count = 0;
void f1()
{
assert(A::count == 0);
assert(C1::count == 0);
assert(C2::count == 0);
assert(B::count == 0);
A a(5);
assert(A::count == 1);
assert(C1::count == 1);
assert(C2::count == 1);
assert(B::count == 1);
assert(a.id_ == 5);
assert(static_cast<C1&>(a).id_ == 4);
assert(static_cast<C2&>(a).id_ == 3);
assert(static_cast<B&>(a).id_ == 8);
throw a;
assert(false);
}
void f2()
{
try
{
assert(A::count == 0);
assert(C1::count == 0);
assert(C2::count == 0);
assert(B::count == 0);
f1();
assert(false);
}
catch (const A& a) // can catch A
{
assert(a.id_ == 5);
assert(static_cast<const C1&>(a).id_ == 4);
assert(static_cast<const C2&>(a).id_ == 3);
assert(static_cast<const B&>(a).id_ == 8);
throw;
}
catch (const C1&)
{
assert(false);
}
catch (const C2&)
{
assert(false);
}
catch (const B&)
{
assert(false);
}
}
void f3()
{
try
{
assert(A::count == 0);
assert(C1::count == 0);
assert(C2::count == 0);
assert(B::count == 0);
f2();
assert(false);
}
catch (const B& a) // can catch B
{
assert(static_cast<const B&>(a).id_ == 8);
throw;
}
catch (const C1& c1)
{
assert(false);
}
catch (const C2&)
{
assert(false);
}
}
void f4()
{
try
{
assert(A::count == 0);
assert(C1::count == 0);
assert(C2::count == 0);
assert(B::count == 0);
f3();
assert(false);
}
catch (const C2& c2) // can catch C2
{
assert(c2.id_ == 3);
throw;
}
catch (const B& a) // can not catch B (ambiguous base)
{
assert(false);
}
catch (const C1&)
{
assert(false);
}
}
void f5()
{
try
{
assert(A::count == 0);
assert(C1::count == 0);
assert(C2::count == 0);
assert(B::count == 0);
f4();
assert(false);
}
catch (const C1& c1) // can catch C1
{
assert(c1.id_ == 4);
assert(static_cast<const B&>(c1).id_ == 8);
throw;
}
catch (const B& a)
{
assert(false);
}
catch (const C2&)
{
assert(false);
}
}
int main()
{
try
{
f5();
assert(false);
}
catch (...)
{
}
assert(A::count == 0);
assert(C1::count == 0);
assert(C2::count == 0);
assert(B::count == 0);
}

View File

@@ -0,0 +1,148 @@
//===--------------------- catch_const_pointer_nullptr.cpp ----------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: libcxxabi-no-exceptions
#include <cassert>
// Clang emits warnings about exceptions of type 'Child' being caught by
// an earlier handler of type 'Base'. Congrats clang, you've just
// diagnosed the behavior under test.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wexceptions"
#endif
#if __has_feature(cxx_nullptr)
struct A {};
void test1()
{
try
{
throw nullptr;
assert(false);
}
catch (A* p)
{
assert(!p);
}
catch (const A*)
{
assert(false);
}
}
void test2()
{
try
{
throw nullptr;
assert(false);
}
catch (const A* p)
{
assert(!p);
}
catch (A*)
{
assert(false);
}
}
void test3()
{
try
{
throw nullptr;
assert(false);
}
catch (const A* const p)
{
assert(!p);
}
catch (A*)
{
assert(false);
}
}
void test4()
{
try
{
throw nullptr;
assert(false);
}
catch (A* p)
{
assert(!p);
}
catch (const A* const)
{
assert(false);
}
}
void test5()
{
try
{
throw nullptr;
assert(false);
}
catch (A const* p)
{
assert(!p);
}
catch (A*)
{
assert(false);
}
}
void test6()
{
try
{
throw nullptr;
assert(false);
}
catch (A* p)
{
assert(!p);
}
catch (A const*)
{
assert(false);
}
}
#else
void test1() {}
void test2() {}
void test3() {}
void test4() {}
void test5() {}
void test6() {}
#endif
int main()
{
test1();
test2();
test3();
test4();
test5();
test6();
}

View File

@@ -0,0 +1,52 @@
//===----------------------- catch_function_01.cpp ------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// Can you have a catch clause of array type that catches anything?
// GCC incorrectly allows function pointer to be caught by reference.
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69372
// XFAIL: gcc
// UNSUPPORTED: libcxxabi-no-exceptions
#include <cassert>
template <class Tp>
bool can_convert(Tp) { return true; }
template <class>
bool can_convert(...) { return false; }
void f() {}
int main()
{
typedef void Function();
assert(!can_convert<Function&>(&f));
assert(!can_convert<void*>(&f));
try
{
throw f; // converts to void (*)()
assert(false);
}
catch (Function& b) // can't catch void (*)()
{
assert(false);
}
catch (void*) // can't catch as void*
{
assert(false);
}
catch(Function*)
{
}
catch (...)
{
assert(false);
}
}

View File

@@ -0,0 +1,32 @@
//===---------------------- catch_function_02.cpp -------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// Can you have a catch clause of array type that catches anything?
// UNSUPPORTED: libcxxabi-no-exceptions
#include <cassert>
void f() {}
int main()
{
typedef void Function();
try
{
throw f; // converts to void (*)()
assert(false);
}
catch (Function b) // equivalent to void (*)()
{
}
catch (...)
{
assert(false);
}
}

View File

@@ -0,0 +1,64 @@
//===---------------------- catch_function_03.cpp -------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// Can a noexcept function pointer be caught by a non-noexcept catch clause?
// UNSUPPORTED: libcxxabi-no-exceptions, libcxxabi-no-noexcept-function-type
#include <cassert>
template<bool Noexcept> void f() noexcept(Noexcept) {}
template<bool Noexcept> using FnType = void() noexcept(Noexcept);
template<bool ThrowNoexcept, bool CatchNoexcept>
void check()
{
try
{
auto *p = f<ThrowNoexcept>;
throw p;
assert(false);
}
catch (FnType<CatchNoexcept> *p)
{
assert(ThrowNoexcept || !CatchNoexcept);
assert(p == &f<ThrowNoexcept>);
}
catch (...)
{
assert(!ThrowNoexcept && CatchNoexcept);
}
}
void check_deep() {
auto *p = f<true>;
try
{
throw &p;
}
catch (FnType<false> **q)
{
assert(false);
}
catch (FnType<true> **q)
{
}
catch (...)
{
assert(false);
}
}
int main()
{
check<false, false>();
check<false, true>();
check<true, false>();
check<true, true>();
check_deep();
}

View File

@@ -0,0 +1,36 @@
//===---------------------- catch_in_noexcept.cpp--------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, libcxxabi-no-exceptions
#include <exception>
#include <stdlib.h>
#include <assert.h>
struct A {};
// Despite being marked as noexcept, this function must have an EHT entry that
// is not 'cantunwind', so that the unwinder can correctly deal with the throw.
void f1() noexcept
{
try {
A a;
throw a;
assert(false);
} catch (...) {
assert(true);
return;
}
assert(false);
}
int main()
{
f1();
}

View File

@@ -0,0 +1,175 @@
//===----------------- catch_member_data_pointer_01.cpp -------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: libcxxabi-no-exceptions
#include <cassert>
struct A
{
A() : i(0), j(0) {} // explicitly initialize 'i' to prevent warnings
const int i;
int j;
};
typedef const int A::*md1;
typedef int A::*md2;
struct B : public A
{
B() : k(0), l(0) {} // explicitly initialize 'k' to prevent warnings.
const int k;
int l;
};
typedef const int B::*der1;
typedef int B::*der2;
void test1()
{
try
{
throw &A::i;
assert(false);
}
catch (md2)
{
assert(false);
}
catch (md1)
{
}
}
// Check that cv qualified conversions are allowed.
void test2()
{
try
{
throw &A::j;
}
catch (md2)
{
}
catch (...)
{
assert(false);
}
try
{
throw &A::j;
assert(false);
}
catch (md1)
{
}
catch (...)
{
assert(false);
}
}
// Check that Base -> Derived conversions are NOT allowed.
void test3()
{
try
{
throw &A::i;
assert(false);
}
catch (md2)
{
assert(false);
}
catch (der2)
{
assert(false);
}
catch (der1)
{
assert(false);
}
catch (md1)
{
}
}
// Check that Base -> Derived conversions NOT are allowed with different cv
// qualifiers.
void test4()
{
try
{
throw &A::j;
assert(false);
}
catch (der2)
{
assert(false);
}
catch (der1)
{
assert(false);
}
catch (md2)
{
}
catch (...)
{
assert(false);
}
}
// Check that no Derived -> Base conversions are allowed.
void test5()
{
try
{
throw &B::k;
assert(false);
}
catch (md1)
{
assert(false);
}
catch (md2)
{
assert(false);
}
catch (der1)
{
}
try
{
throw &B::l;
assert(false);
}
catch (md1)
{
assert(false);
}
catch (md2)
{
assert(false);
}
catch (der2)
{
}
}
int main()
{
test1();
test2();
test3();
test4();
test5();
}

View File

@@ -0,0 +1,171 @@
//===--------------- catch_member_function_pointer_01.cpp -----------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// GCC incorrectly allows PMF type "void (T::*)()" to be caught as "void (T::*)() const"
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69375
// XFAIL: gcc
// UNSUPPORTED: libcxxabi-no-exceptions
#include <cassert>
struct A
{
void foo() {}
void bar() const {}
};
typedef void (A::*mf1)();
typedef void (A::*mf2)() const;
struct B : public A
{
};
typedef void (B::*dmf1)();
typedef void (B::*dmf2)() const;
template <class Tp>
bool can_convert(Tp) { return true; }
template <class>
bool can_convert(...) { return false; }
void test1()
{
try
{
throw &A::foo;
assert(false);
}
catch (mf2)
{
assert(false);
}
catch (mf1)
{
}
}
void test2()
{
try
{
throw &A::bar;
assert(false);
}
catch (mf1)
{
assert(false);
}
catch (mf2)
{
}
}
void test_derived()
{
try
{
throw (mf1)0;
assert(false);
}
catch (dmf2)
{
assert(false);
}
catch (dmf1)
{
assert(false);
}
catch (mf1)
{
}
try
{
throw (mf2)0;
assert(false);
}
catch (dmf1)
{
assert(false);
}
catch (dmf2)
{
assert(false);
}
catch (mf2)
{
}
assert(!can_convert<mf1>((dmf1)0));
assert(!can_convert<mf2>((dmf1)0));
try
{
throw (dmf1)0;
assert(false);
}
catch (mf2)
{
assert(false);
}
catch (mf1)
{
assert(false);
}
catch (...)
{
}
assert(!can_convert<mf1>((dmf2)0));
assert(!can_convert<mf2>((dmf2)0));
try
{
throw (dmf2)0;
assert(false);
}
catch (mf2)
{
assert(false);
}
catch (mf1)
{
assert(false);
}
catch (...)
{
}
}
void test_void()
{
assert(!can_convert<void*>(&A::foo));
try
{
throw &A::foo;
assert(false);
}
catch (void*)
{
assert(false);
}
catch(...)
{
}
}
int main()
{
test1();
test2();
test_derived();
test_void();
}

View File

@@ -0,0 +1,71 @@
//===--------------- catch_member_function_pointer_02.cpp -----------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// Can a noexcept member function pointer be caught by a non-noexcept catch
// clause?
// UNSUPPORTED: libcxxabi-no-exceptions, libcxxabi-no-noexcept-function-type
// GCC 7 and 8 support noexcept function types but this test still fails.
// This is likely a bug in their implementation. Investigation needed.
// XFAIL: gcc-7, gcc-8
#include <cassert>
struct X {
template<bool Noexcept> void f() noexcept(Noexcept) {}
};
template<bool Noexcept> using FnType = void (X::*)() noexcept(Noexcept);
template<bool ThrowNoexcept, bool CatchNoexcept>
void check()
{
try
{
auto p = &X::f<ThrowNoexcept>;
throw p;
assert(false);
}
catch (FnType<CatchNoexcept> p)
{
assert(ThrowNoexcept || !CatchNoexcept);
assert(p == &X::f<ThrowNoexcept>);
}
catch (...)
{
assert(!ThrowNoexcept && CatchNoexcept);
}
}
void check_deep() {
FnType<true> p = &X::f<true>;
try
{
throw &p;
}
catch (FnType<false> *q)
{
assert(false);
}
catch (FnType<true> *q)
{
}
catch (...)
{
assert(false);
}
}
int main()
{
check<false, false>();
check<false, true>();
check<true, false>();
check<true, true>();
check_deep();
}

View File

@@ -0,0 +1,75 @@
//===----------------- catch_member_pointer_nullptr.cpp -------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: libcxxabi-no-exceptions
#include <cassert>
#if __has_feature(cxx_nullptr)
struct A
{
const int i;
int j;
};
typedef const int A::*md1;
typedef int A::*md2;
void test1()
{
try
{
throw nullptr;
assert(false);
}
catch (md2 p)
{
assert(!p);
}
catch (md1)
{
assert(false);
}
}
void test2()
{
try
{
throw nullptr;
assert(false);
}
catch (md1 p)
{
assert(!p);
}
catch (md2)
{
assert(false);
}
}
#else
void test1()
{
}
void test2()
{
}
#endif
int main()
{
test1();
test2();
}

View File

@@ -0,0 +1,145 @@
//===--------------------- catch_pointer_nullptr.cpp ----------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: libcxxabi-no-exceptions
#include <cassert>
#include <cstdlib>
#include <iostream>
// Roll our own assertion macro to get better error messages out of the tests.
// In particular on systems that don't use __PRETTY_FUNCTION__ in assertions.
#define my_assert(pred, msg) do_assert(pred, msg, __LINE__, __PRETTY_FUNCTION__)
void do_assert(bool assert_passed, const char* msg, int line, const char* func) {
if (assert_passed) return;
std::cerr << __FILE__ << ":" << line << " " << func
<< ": Assertion Failed `" << msg << "'\n\n";
std::abort();
}
struct A {};
struct Base {};
struct Derived : public Base {};
template <class To>
bool test_conversion(To) { return true; }
template <class To>
bool test_conversion(...) { return false; }
template <class Pointer>
struct CreatePointer {
Pointer operator()() const {
return (Pointer)0;
}
};
template <class Tp>
struct CreatePointer<Tp*> {
Tp* operator()() const {
return (Tp*)42;
}
};
template <class Throw, class Catch>
void catch_pointer_test() {
Throw throw_ptr = CreatePointer<Throw>()();
// Use the compiler to determine if the exception of type Throw can be
// implicitly converted to type Catch.
const bool can_convert = test_conversion<Catch>(throw_ptr);
try {
throw throw_ptr;
assert(false);
} catch (Catch catch_ptr) {
Catch catch2 = CreatePointer<Catch>()();
my_assert(can_convert, "non-convertible type incorrectly caught");
my_assert(catch_ptr == catch2,
"Thrown pointer does not match caught ptr");
} catch (...) {
my_assert(!can_convert, "convertible type incorrectly not caught");
}
}
// Generate CV qualified pointer typedefs.
template <class Tp, bool First = false>
struct TestTypes {
typedef Tp* Type;
typedef Tp const* CType;
typedef Tp volatile* VType;
typedef Tp const volatile* CVType;
};
// Special case for cv-qualifying a pointer-to-member without adding an extra
// pointer to it.
template <class Member, class Class>
struct TestTypes<Member Class::*, true> {
typedef Member (Class::*Type);
typedef const Member (Class::*CType);
typedef volatile Member (Class::*VType);
typedef const volatile Member (Class::*CVType);
};
template <class Throw, class Catch, int level, bool first = false>
struct generate_tests_imp {
typedef TestTypes<Throw, first> ThrowTypes;
typedef TestTypes<Catch, first> CatchTypes;
void operator()() {
typedef typename ThrowTypes::Type Type;
typedef typename ThrowTypes::CType CType;
typedef typename ThrowTypes::VType VType;
typedef typename ThrowTypes::CVType CVType;
run_catch_tests<Type>();
run_catch_tests<CType>();
run_catch_tests<VType>();
run_catch_tests<CVType>();
}
template <class ThrowTp>
void run_catch_tests() {
typedef typename CatchTypes::Type Type;
typedef typename CatchTypes::CType CType;
typedef typename CatchTypes::VType VType;
typedef typename CatchTypes::CVType CVType;
catch_pointer_test<ThrowTp, Type>();
catch_pointer_test<ThrowTp, CType>();
catch_pointer_test<ThrowTp, VType>();
catch_pointer_test<ThrowTp, CVType>();
generate_tests_imp<ThrowTp, Type, level-1>()();
generate_tests_imp<ThrowTp, CType, level-1>()();
generate_tests_imp<ThrowTp, VType, level-1>()();
generate_tests_imp<ThrowTp, CVType, level-1>()();
}
};
template <class Throw, class Catch, bool first>
struct generate_tests_imp<Throw, Catch, 0, first> {
void operator()() {
catch_pointer_test<Throw, Catch>();
}
};
template <class Throw, class Catch, int level>
struct generate_tests : generate_tests_imp<Throw, Catch, level, true> {};
int main()
{
generate_tests<int, int, 3>()();
generate_tests<Base, Derived, 2>()();
generate_tests<Derived, Base, 2>()();
generate_tests<int, void, 2>()();
generate_tests<void, int, 2>()();
generate_tests<int A::*, int A::*, 3>()();
generate_tests<int A::*, void, 2>()();
generate_tests<void, int A::*, 2>()();
}

View File

@@ -0,0 +1,75 @@
//===--------------------- catch_pointer_nullptr.cpp ----------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, libcxxabi-no-exceptions
#include <cassert>
#include <cstdlib>
struct A {};
void test1()
{
try
{
throw nullptr;
assert(false);
}
catch (int* p)
{
assert(!p);
}
catch (long*)
{
assert(false);
}
}
void test2()
{
try
{
throw nullptr;
assert(false);
}
catch (A* p)
{
assert(!p);
}
catch (int*)
{
assert(false);
}
}
template <class Catch>
void catch_nullptr_test() {
try {
throw nullptr;
assert(false);
} catch (Catch c) {
assert(!c);
} catch (...) {
assert(false);
}
}
int main()
{
// catch naked nullptrs
test1();
test2();
catch_nullptr_test<int*>();
catch_nullptr_test<int**>();
catch_nullptr_test<int A::*>();
catch_nullptr_test<const int A::*>();
catch_nullptr_test<int A::**>();
}

View File

@@ -0,0 +1,446 @@
//===---------------------- catch_pointer_referece.cpp --------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This test case checks specifically the cases under bullet 3.1 & 3.2:
//
// C++ ABI 15.3:
// A handler is a match for an exception object of type E if
// * The handler is of type cv T or cv T& and E and T are the same type
// (ignoring the top-level cv-qualifiers), or
// * the handler is of type cv T or cv T& and T is an unambiguous base
// class of E, or
// / * the handler is of type cv1 T* cv2 and E is a pointer type that can \
// | be converted to the type of the handler by either or both of |
// | o a standard pointer conversion (4.10 [conv.ptr]) not involving |
// | conversions to private or protected or ambiguous classes |
// \ o a qualification conversion /
// * the handler is a pointer or pointer to member type and E is
// std::nullptr_t
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: libcxxabi-no-exceptions
#include <exception>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
struct Base {};
struct Derived : Base {};
struct Derived2 : Base {};
struct Ambiguous : Derived, Derived2 {};
struct Private : private Base {};
struct Protected : protected Base {};
template <typename T // Handler type
,typename E // Thrown exception type
,typename O // Object type
>
void assert_catches()
{
try
{
O o;
throw static_cast<E>(&o);
printf("%s\n", __PRETTY_FUNCTION__);
assert(false && "Statements after throw must be unreachable");
}
catch (T t)
{
assert(true);
return;
}
catch (...)
{
printf("%s\n", __PRETTY_FUNCTION__);
assert(false && "Should not have entered catch-all");
}
printf("%s\n", __PRETTY_FUNCTION__);
assert(false && "The catch should have returned");
}
template <typename T // Handler type
,typename E // Thrown exception type
,typename O // Object type
>
void assert_cannot_catch()
{
try
{
O o;
throw static_cast<E>(&o);
printf("%s\n", __PRETTY_FUNCTION__);
assert(false && "Statements after throw must be unreachable");
}
catch (T t)
{
printf("%s\n", __PRETTY_FUNCTION__);
assert(false && "Should not have entered the catch");
}
catch (...)
{
assert(true);
return;
}
printf("%s\n", __PRETTY_FUNCTION__);
assert(false && "The catch-all should have returned");
}
void f1()
{
// Test that every combination of handler of type:
// cv1 Base * cv2
// catches an exception of type:
// Derived *
assert_catches< Base * , Derived *, Derived>();
assert_catches<const Base * , Derived *, Derived>();
assert_catches< volatile Base * , Derived *, Derived>();
assert_catches<const volatile Base * , Derived *, Derived>();
assert_catches< Base * const , Derived *, Derived>();
assert_catches<const Base * const , Derived *, Derived>();
assert_catches< volatile Base * const , Derived *, Derived>();
assert_catches<const volatile Base * const , Derived *, Derived>();
assert_catches< Base * volatile, Derived *, Derived>();
assert_catches<const Base * volatile, Derived *, Derived>();
assert_catches< volatile Base * volatile, Derived *, Derived>();
assert_catches<const volatile Base * volatile, Derived *, Derived>();
assert_catches< Base * const volatile, Derived *, Derived>();
assert_catches<const Base * const volatile, Derived *, Derived>();
assert_catches< volatile Base * const volatile, Derived *, Derived>();
assert_catches<const volatile Base * const volatile, Derived *, Derived>();
}
void f2()
{
// Test that every combination of handler of type:
// cv1 Base * cv2
// catches an exception of type:
// Base *
assert_catches< Base * , Base *, Derived>();
assert_catches<const Base * , Base *, Derived>();
assert_catches< volatile Base * , Base *, Derived>();
assert_catches<const volatile Base * , Base *, Derived>();
assert_catches< Base * const , Base *, Derived>();
assert_catches<const Base * const , Base *, Derived>();
assert_catches< volatile Base * const , Base *, Derived>();
assert_catches<const volatile Base * const , Base *, Derived>();
assert_catches< Base * volatile, Base *, Derived>();
assert_catches<const Base * volatile, Base *, Derived>();
assert_catches< volatile Base * volatile, Base *, Derived>();
assert_catches<const volatile Base * volatile, Base *, Derived>();
assert_catches< Base * const volatile, Base *, Derived>();
assert_catches<const Base * const volatile, Base *, Derived>();
assert_catches< volatile Base * const volatile, Base *, Derived>();
assert_catches<const volatile Base * const volatile, Base *, Derived>();
}
void f3()
{
// Test that every combination of handler of type:
// cv1 Derived * cv2
// catches an exception of type:
// Derived *
assert_catches< Derived * , Derived *, Derived>();
assert_catches<const Derived * , Derived *, Derived>();
assert_catches< volatile Derived * , Derived *, Derived>();
assert_catches<const volatile Derived * , Derived *, Derived>();
assert_catches< Derived * const , Derived *, Derived>();
assert_catches<const Derived * const , Derived *, Derived>();
assert_catches< volatile Derived * const , Derived *, Derived>();
assert_catches<const volatile Derived * const , Derived *, Derived>();
assert_catches< Derived * volatile, Derived *, Derived>();
assert_catches<const Derived * volatile, Derived *, Derived>();
assert_catches< volatile Derived * volatile, Derived *, Derived>();
assert_catches<const volatile Derived * volatile, Derived *, Derived>();
assert_catches< Derived * const volatile, Derived *, Derived>();
assert_catches<const Derived * const volatile, Derived *, Derived>();
assert_catches< volatile Derived * const volatile, Derived *, Derived>();
assert_catches<const volatile Derived * const volatile, Derived *, Derived>();
}
void f4()
{
// Test that every combination of handler of type:
// cv1 Derived * cv2
// cannot catch an exception of type:
// Base *
assert_cannot_catch< Derived * , Base *, Derived>();
assert_cannot_catch<const Derived * , Base *, Derived>();
assert_cannot_catch< volatile Derived * , Base *, Derived>();
assert_cannot_catch<const volatile Derived * , Base *, Derived>();
assert_cannot_catch< Derived * const , Base *, Derived>();
assert_cannot_catch<const Derived * const , Base *, Derived>();
assert_cannot_catch< volatile Derived * const , Base *, Derived>();
assert_cannot_catch<const volatile Derived * const , Base *, Derived>();
assert_cannot_catch< Derived * volatile, Base *, Derived>();
assert_cannot_catch<const Derived * volatile, Base *, Derived>();
assert_cannot_catch< volatile Derived * volatile, Base *, Derived>();
assert_cannot_catch<const volatile Derived * volatile, Base *, Derived>();
assert_cannot_catch< Derived * const volatile, Base *, Derived>();
assert_cannot_catch<const Derived * const volatile, Base *, Derived>();
assert_cannot_catch< volatile Derived * const volatile, Base *, Derived>();
assert_cannot_catch<const volatile Derived * const volatile, Base *, Derived>();
}
void f5()
{
// Test that every combination of handler of type:
// cv1 Derived * cv2 &
// catches an exception of type:
// Derived *
assert_catches< Derived * &, Derived *, Derived>();
assert_catches<const Derived * &, Derived *, Derived>();
assert_catches< volatile Derived * &, Derived *, Derived>();
assert_catches<const volatile Derived * &, Derived *, Derived>();
assert_catches< Derived * const &, Derived *, Derived>();
assert_catches<const Derived * const &, Derived *, Derived>();
assert_catches< volatile Derived * const &, Derived *, Derived>();
assert_catches<const volatile Derived * const &, Derived *, Derived>();
assert_catches< Derived * volatile &, Derived *, Derived>();
assert_catches<const Derived * volatile &, Derived *, Derived>();
assert_catches< volatile Derived * volatile &, Derived *, Derived>();
assert_catches<const volatile Derived * volatile &, Derived *, Derived>();
assert_catches< Derived * const volatile &, Derived *, Derived>();
assert_catches<const Derived * const volatile &, Derived *, Derived>();
assert_catches< volatile Derived * const volatile &, Derived *, Derived>();
assert_catches<const volatile Derived * const volatile &, Derived *, Derived>();
}
void f6()
{
// Test that every combination of handler of type:
// cv1 Base * cv2 &
// catches an exception of type:
// Base *
assert_catches< Base * &, Base *, Derived>();
assert_catches<const Base * &, Base *, Derived>();
assert_catches< volatile Base * &, Base *, Derived>();
assert_catches<const volatile Base * &, Base *, Derived>();
assert_catches< Base * const &, Base *, Derived>();
assert_catches<const Base * const &, Base *, Derived>();
assert_catches< volatile Base * const &, Base *, Derived>();
assert_catches<const volatile Base * const &, Base *, Derived>();
assert_catches< Base * volatile &, Base *, Derived>();
assert_catches<const Base * volatile &, Base *, Derived>();
assert_catches< volatile Base * volatile &, Base *, Derived>();
assert_catches<const volatile Base * volatile &, Base *, Derived>();
assert_catches< Base * const volatile &, Base *, Derived>();
assert_catches<const Base * const volatile &, Base *, Derived>();
assert_catches< volatile Base * const volatile &, Base *, Derived>();
assert_catches<const volatile Base * const volatile &, Base *, Derived>();
}
void f7()
{
// Test that every combination of handler of type:
// cv1 Derived * cv2 &
// cannot catch an exception of type:
// Base *
assert_cannot_catch< Derived * &, Base *, Derived>();
assert_cannot_catch<const Derived * &, Base *, Derived>();
assert_cannot_catch< volatile Derived * &, Base *, Derived>();
assert_cannot_catch<const volatile Derived * &, Base *, Derived>();
assert_cannot_catch< Derived * const &, Base *, Derived>();
assert_cannot_catch<const Derived * const &, Base *, Derived>();
assert_cannot_catch< volatile Derived * const &, Base *, Derived>();
assert_cannot_catch<const volatile Derived * const &, Base *, Derived>();
assert_cannot_catch< Derived * volatile &, Base *, Derived>();
assert_cannot_catch<const Derived * volatile &, Base *, Derived>();
assert_cannot_catch< volatile Derived * volatile &, Base *, Derived>();
assert_cannot_catch<const volatile Derived * volatile &, Base *, Derived>();
assert_cannot_catch< Derived * const volatile &, Base *, Derived>();
assert_cannot_catch<const Derived * const volatile &, Base *, Derived>();
assert_cannot_catch< volatile Derived * const volatile &, Base *, Derived>();
assert_cannot_catch<const volatile Derived * const volatile &, Base *, Derived>();
}
void f8()
{
// This test case has a caveat noted in the discussion here:
// https://gcc.gnu.org/ml/gcc-patches/2009-08/msg00264.html
// Specifically:
// This [test exposes a] corner case of the ARM C++ ABI. The generic C++
// ABI also gets this wrong, because I failed to notice the subtlety here.
// The issue is that 15.3/3 3rd bullet says:
// The handler is of type cv1 T* cv2 and E is a pointer type that
// can be converted to the type of the handler by either or both of:
// * a standard pointer conversion (4.10) not involving conversions
// to pointers to private or protected or ambiguous classes
// Notice that the handlers of type "cv1 T*cv2&" are not allowed such
// freedom to find a base class. The ABI error is that we treat handlers
// of reference type exactly the same as the corresponding hander of
// non-reference type. Elsewhere in the exception handling this makes no
// difference (for instance bullet 1 explicitly says 'cv T or cv T&').
//
// See also: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#388
//
// TL;DR: it is an unresolved C++ ABI defect that these do catch
// Test that every combination of handler of type:
// cv1 Base * cv2 &
// catches an exception of type:
// Derived *
assert_catches< Base * &, Derived *, Derived>();
assert_catches<const Base * &, Derived *, Derived>();
assert_catches< volatile Base * &, Derived *, Derived>();
assert_catches<const volatile Base * &, Derived *, Derived>();
assert_catches< Base * const &, Derived *, Derived>();
assert_catches<const Base * const &, Derived *, Derived>();
assert_catches< volatile Base * const &, Derived *, Derived>();
assert_catches<const volatile Base * const &, Derived *, Derived>();
assert_catches< Base * volatile &, Derived *, Derived>();
assert_catches<const Base * volatile &, Derived *, Derived>();
assert_catches< volatile Base * volatile &, Derived *, Derived>();
assert_catches<const volatile Base * volatile &, Derived *, Derived>();
assert_catches< Base * const volatile &, Derived *, Derived>();
assert_catches<const Base * const volatile &, Derived *, Derived>();
assert_catches< volatile Base * const volatile &, Derived *, Derived>();
assert_catches<const volatile Base * const volatile &, Derived *, Derived>();
}
void f9()
{
// Test that every combination of handler of type:
// cv1 Base * cv2
// cannot catch an exception of type:
// Ambiguous *
assert_cannot_catch< Base * , Ambiguous *, Ambiguous>();
assert_cannot_catch<const Base * , Ambiguous *, Ambiguous>();
assert_cannot_catch< volatile Base * , Ambiguous *, Ambiguous>();
assert_cannot_catch<const volatile Base * , Ambiguous *, Ambiguous>();
assert_cannot_catch< Base * const , Ambiguous *, Ambiguous>();
assert_cannot_catch<const Base * const , Ambiguous *, Ambiguous>();
assert_cannot_catch< volatile Base * const , Ambiguous *, Ambiguous>();
assert_cannot_catch<const volatile Base * const , Ambiguous *, Ambiguous>();
assert_cannot_catch< Base * volatile, Ambiguous *, Ambiguous>();
assert_cannot_catch<const Base * volatile, Ambiguous *, Ambiguous>();
assert_cannot_catch< volatile Base * volatile, Ambiguous *, Ambiguous>();
assert_cannot_catch<const volatile Base * volatile, Ambiguous *, Ambiguous>();
assert_cannot_catch< Base * const volatile, Ambiguous *, Ambiguous>();
assert_cannot_catch<const Base * const volatile, Ambiguous *, Ambiguous>();
assert_cannot_catch< volatile Base * const volatile, Ambiguous *, Ambiguous>();
assert_cannot_catch<const volatile Base * const volatile, Ambiguous *, Ambiguous>();
}
void f10()
{
// Test that every combination of handler of type:
// cv1 Base * cv2
// cannot catch an exception of type:
// Private *
assert_cannot_catch< Base * , Private *, Private>();
assert_cannot_catch<const Base * , Private *, Private>();
assert_cannot_catch< volatile Base * , Private *, Private>();
assert_cannot_catch<const volatile Base * , Private *, Private>();
assert_cannot_catch< Base * const , Private *, Private>();
assert_cannot_catch<const Base * const , Private *, Private>();
assert_cannot_catch< volatile Base * const , Private *, Private>();
assert_cannot_catch<const volatile Base * const , Private *, Private>();
assert_cannot_catch< Base * volatile, Private *, Private>();
assert_cannot_catch<const Base * volatile, Private *, Private>();
assert_cannot_catch< volatile Base * volatile, Private *, Private>();
assert_cannot_catch<const volatile Base * volatile, Private *, Private>();
assert_cannot_catch< Base * const volatile, Private *, Private>();
assert_cannot_catch<const Base * const volatile, Private *, Private>();
assert_cannot_catch< volatile Base * const volatile, Private *, Private>();
assert_cannot_catch<const volatile Base * const volatile, Private *, Private>();
}
void f11()
{
// Test that every combination of handler of type:
// cv1 Base * cv2
// cannot catch an exception of type:
// Protected *
assert_cannot_catch< Base * , Protected *, Protected>();
assert_cannot_catch<const Base * , Protected *, Protected>();
assert_cannot_catch< volatile Base * , Protected *, Protected>();
assert_cannot_catch<const volatile Base * , Protected *, Protected>();
assert_cannot_catch< Base * const , Protected *, Protected>();
assert_cannot_catch<const Base * const , Protected *, Protected>();
assert_cannot_catch< volatile Base * const , Protected *, Protected>();
assert_cannot_catch<const volatile Base * const , Protected *, Protected>();
assert_cannot_catch< Base * volatile, Protected *, Protected>();
assert_cannot_catch<const Base * volatile, Protected *, Protected>();
assert_cannot_catch< volatile Base * volatile, Protected *, Protected>();
assert_cannot_catch<const volatile Base * volatile, Protected *, Protected>();
assert_cannot_catch< Base * const volatile, Protected *, Protected>();
assert_cannot_catch<const Base * const volatile, Protected *, Protected>();
assert_cannot_catch< volatile Base * const volatile, Protected *, Protected>();
assert_cannot_catch<const volatile Base * const volatile, Protected *, Protected>();
}
void f12()
{
// Test that every combination of handler of type:
// cv1 Base * cv2 &
// cannot catch an exception of type:
// Private *
assert_cannot_catch< Base * &, Private *, Private>();
assert_cannot_catch<const Base * &, Private *, Private>();
assert_cannot_catch< volatile Base * &, Private *, Private>();
assert_cannot_catch<const volatile Base * &, Private *, Private>();
assert_cannot_catch< Base * const &, Private *, Private>();
assert_cannot_catch<const Base * const &, Private *, Private>();
assert_cannot_catch< volatile Base * const &, Private *, Private>();
assert_cannot_catch<const volatile Base * const &, Private *, Private>();
assert_cannot_catch< Base * volatile &, Private *, Private>();
assert_cannot_catch<const Base * volatile &, Private *, Private>();
assert_cannot_catch< volatile Base * volatile &, Private *, Private>();
assert_cannot_catch<const volatile Base * volatile &, Private *, Private>();
assert_cannot_catch< Base * const volatile &, Private *, Private>();
assert_cannot_catch<const Base * const volatile &, Private *, Private>();
assert_cannot_catch< volatile Base * const volatile &, Private *, Private>();
assert_cannot_catch<const volatile Base * const volatile &, Private *, Private>();
}
void f13()
{
// Test that every combination of handler of type:
// cv1 Base * cv2 &
// cannot catch an exception of type:
// Protected *
assert_cannot_catch< Base * &, Protected *, Protected>();
assert_cannot_catch<const Base * &, Protected *, Protected>();
assert_cannot_catch< volatile Base * &, Protected *, Protected>();
assert_cannot_catch<const volatile Base * &, Protected *, Protected>();
assert_cannot_catch< Base * const &, Protected *, Protected>();
assert_cannot_catch<const Base * const &, Protected *, Protected>();
assert_cannot_catch< volatile Base * const &, Protected *, Protected>();
assert_cannot_catch<const volatile Base * const &, Protected *, Protected>();
assert_cannot_catch< Base * volatile &, Protected *, Protected>();
assert_cannot_catch<const Base * volatile &, Protected *, Protected>();
assert_cannot_catch< volatile Base * volatile &, Protected *, Protected>();
assert_cannot_catch<const volatile Base * volatile &, Protected *, Protected>();
assert_cannot_catch< Base * const volatile &, Protected *, Protected>();
assert_cannot_catch<const Base * const volatile &, Protected *, Protected>();
assert_cannot_catch< volatile Base * const volatile &, Protected *, Protected>();
assert_cannot_catch<const volatile Base * const volatile &, Protected *, Protected>();
}
int main()
{
f1();
f2();
f3();
f4();
f5();
f6();
f7();
f8();
f9();
f10();
f11();
f12();
f13();
}

Some files were not shown because too many files have changed in this diff Show More