CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
130 lines
3.1 KiB
C++
130 lines
3.1 KiB
C++
// RUN: %check_clang_tidy -std=c++11,c++14 %s bugprone-exception-copy-constructor-throws %t -- -- -fcxx-exceptions
|
|
// FIXME: Split off parts of this test that rely on dynamic exception
|
|
// specifications, and run this test in all language modes.
|
|
// FIXME: Fix the checker to work in C++17 or later mode.
|
|
struct S {};
|
|
struct T : S {};
|
|
struct U {
|
|
U() = default;
|
|
U(const U&) = default;
|
|
};
|
|
|
|
struct V {
|
|
V() = default;
|
|
V(const V&) noexcept;
|
|
};
|
|
|
|
struct W {
|
|
W() = default;
|
|
W(const W&) noexcept(false);
|
|
};
|
|
|
|
struct X {
|
|
X() = default;
|
|
X(const X&) {}
|
|
};
|
|
|
|
struct Y {
|
|
Y() = default;
|
|
Y(const Y&) throw();
|
|
};
|
|
|
|
struct Z {
|
|
Z() = default;
|
|
Z(const Z&) throw(int);
|
|
};
|
|
|
|
void g() noexcept(false);
|
|
|
|
struct A {
|
|
A() = default;
|
|
A(const A&) noexcept(noexcept(g()));
|
|
};
|
|
|
|
struct B {
|
|
B() = default;
|
|
B(const B&) = default;
|
|
B(const A&) noexcept(false);
|
|
};
|
|
|
|
class C {
|
|
W M; // W is not no-throw copy constructible
|
|
public:
|
|
C() = default;
|
|
C(const C&) = default;
|
|
};
|
|
|
|
struct D {
|
|
D() = default;
|
|
D(const D&) noexcept(false);
|
|
D(D&) noexcept(true);
|
|
};
|
|
|
|
struct E {
|
|
E() = default;
|
|
E(E&) noexcept(true);
|
|
E(const E&) noexcept(false);
|
|
};
|
|
|
|
struct Allocates {
|
|
int *x;
|
|
Allocates() : x(new int(0)) {}
|
|
Allocates(const Allocates &other) : x(new int(*other.x)) {}
|
|
};
|
|
|
|
struct OptionallyAllocates {
|
|
int *x;
|
|
OptionallyAllocates() : x(new int(0)) {}
|
|
OptionallyAllocates(const Allocates &other) noexcept(true) {
|
|
try {
|
|
x = new int(*other.x);
|
|
} catch (...) {
|
|
x = nullptr;
|
|
}
|
|
}
|
|
};
|
|
|
|
void f() {
|
|
throw 12; // ok
|
|
throw "test"; // ok
|
|
throw S(); // ok
|
|
throw T(); // ok
|
|
throw U(); // ok
|
|
throw V(); // ok
|
|
throw W(); // match, noexcept(false)
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: thrown exception type is not nothrow copy constructible [bugprone-exception-copy-constructor-throws]
|
|
throw X(); // match, no noexcept clause, nontrivial
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: thrown exception type is not nothrow copy constructible
|
|
throw Y(); // ok
|
|
throw Z(); // match, throw(int)
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: thrown exception type is not nothrow copy constructible
|
|
throw A(); // match, noexcept(false)
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: thrown exception type is not nothrow copy constructible
|
|
throw B(); // ok
|
|
throw C(); // match, C has a member variable that makes it throwing on copy
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: thrown exception type is not nothrow copy constructible
|
|
throw D(); // match, has throwing copy constructor
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: thrown exception type is not nothrow copy constructible
|
|
throw E(); // match, has throwing copy constructor
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: thrown exception type is not nothrow copy constructible
|
|
throw Allocates(); // match, copy constructor throws
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: thrown exception type is not nothrow copy constructible
|
|
throw OptionallyAllocates(); // ok
|
|
}
|
|
|
|
namespace PR25574 {
|
|
struct B {
|
|
B(const B&) noexcept;
|
|
};
|
|
|
|
struct D : B {
|
|
D();
|
|
virtual ~D() noexcept;
|
|
};
|
|
|
|
template <typename T>
|
|
void f() {
|
|
throw D();
|
|
}
|
|
}
|