Files
TheRock/compiler/amd-llvm/clang/test/CXX/class.access/class.access.base/p5.cpp
T
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

99 lines
2.3 KiB
C++

// RUN: %clang_cc1 -verify %s
namespace test0 {
struct A {
static int x;
};
struct B : A {};
struct C : B {};
int test() {
return A::x
+ B::x
+ C::x;
}
}
namespace test1 {
struct A {
private: static int x; // expected-note 5 {{declared private here}}
static int test() { return x; }
};
struct B : public A {
static int test() { return x; } // expected-error {{private member}}
};
struct C : private A {
static int test() { return x; } // expected-error {{private member}}
};
struct D {
public: static int x; // expected-note{{member is declared here}}
static int test() { return x; }
};
struct E : private D { // expected-note{{constrained by private inheritance}}
static int test() { return x; }
};
int test() {
return A::x // expected-error {{private member}}
+ B::x // expected-error {{private member}}
+ C::x // expected-error {{private member}}
+ D::x
+ E::x; // expected-error {{private member}}
}
}
namespace test2 {
class A {
protected: static int x; // expected-note{{member is declared here}}
};
class B : private A {}; // expected-note {{private inheritance}}
class C : private A {
int test(B *b) {
return b->x; // expected-error {{private member}}
}
};
}
namespace test3 {
class A {
protected: static int x;
};
class B : public A {};
class C : private A {
int test(B *b) {
// x is accessible at C when named in A.
// A is an accessible base of B at C.
// Therefore this succeeds.
return b->x;
}
};
}
// Don't crash.
// Note that 'field' is indeed a private member of X but that access
// is indeed ultimately constrained by the protected inheritance from Y.
// If someone wants to put the effort into improving this diagnostic,
// they can feel free; even explaining it in person would be a pain.
namespace test4 {
class Z;
class X {
public:
void f(Z *p);
private:
int field; // expected-note {{member is declared here}}
};
class Y : public X { };
class Z : protected Y { }; // expected-note {{constrained by protected inheritance here}}
void X::f(Z *p) {
p->field = 0; // expected-error {{'field' is a private member of 'test4::X'}}
}
}
// TODO: flesh out these cases