Files
TheRock/compiler/amd-llvm/clang/test/SemaCXX/cxx2c-variadic-friends.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

157 lines
2.7 KiB
C++

// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2c %s
struct A;
struct B;
struct C;
struct S {};
template <typename> struct TS {};
template <typename ...Pack>
class X {
friend Pack...;
static void f() { } // expected-note {{declared private here}}
};
class Y {
friend A, B, C;
static void g() { } // expected-note {{declared private here}}
};
struct A {
A() {
X<A>::f();
Y::g();
};
};
struct B {
B() {
X<B, C>::f();
Y::g();
};
};
struct C {
C() {
X<A, B, C>::f();
Y::g();
};
};
struct D {
D() {
X<A, B, C>::f(); // expected-error {{'f' is a private member of 'X<A, B, C>'}}
Y::g(); // expected-error {{'g' is a private member of 'Y'}}
};
};
void f1() {
A a;
B b;
C c;
D d;
}
template <typename ...Pack>
struct Z {
template <template <typename> class Template>
struct Inner {
friend Template<Pack>...;
};
};
void f2() {
Z<int, long, char> z;
Z<int, long, char>::Inner<TS> inner;
}
namespace p2893r3_examples {
template<class... Ts>
class Passkey {
friend Ts...;
Passkey() {} // expected-note {{declared private here}}
};
class Foo;
class Bar;
class Baz;
class C {
public:
void f(Passkey<Foo, Bar, Baz>);
};
class Foo {
Foo() { C c; c.f({}); }
};
class Bar {
Bar() { C c; c.f({}); }
};
class Baz {
Baz() { C c; c.f({}); }
};
class Quux {
Quux() { C c; c.f({}); } // expected-error {{calling a private constructor of class 'p2893r3_examples::Passkey<p2893r3_examples::Foo, p2893r3_examples::Bar, p2893r3_examples::Baz>'}}
};
template<class Derived, class MsgT>
struct Receiver {
void receive(MsgT) {
static_cast<Derived*>(this)->private_ += 1;
}
};
template<class... MsgTs>
struct Dispatcher : Receiver<Dispatcher<MsgTs...>, MsgTs>... {
using Receiver<Dispatcher, MsgTs>::receive...;
friend Receiver<Dispatcher, MsgTs>...;
private:
int private_;
};
void f() {
Dispatcher<int, float> d;
d.receive(0);
d.receive(0.0f);
}
} // namespace p2893r3_examples
namespace p2893r3_note {
template <class... Ts> class R {
friend Ts...;
};
template <class... Ts, class... Us>
class R<R<Ts...>, R<Us...>> {
friend Ts::Nested..., Us...;
};
struct E { struct Nested; };
R<R<E>, R<C, int>> rr;
} // namespace p2893r3_note
namespace template_template {
template <typename U, template <typename> typename... Friend>
class S {
friend class Friend<U>...;
static constexpr int a = 42;
};
template <typename U>
struct T {
static_assert(S<U, T>::a == 42);
static_assert(S<U, T>::a == 43); // expected-error {{static assertion failed due to requirement 'template_template::S<int, template_template::T>::a == 43'}} \
// expected-note {{expression evaluates to '42 == 43'}}
};
void f() {
T<int> t; // expected-note {{in instantiation of}}
}
}