Files
TheRock/compiler/amd-llvm/clang/test/CXX/class.access/class.friend/p9-cxx0x.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

118 lines
2.6 KiB
C++

// RUN: %clang_cc1 -fsyntax-only -verify %s
// C++98 [class.friend]p7:
// C++11 [class.friend]p9:
// A name nominated by a friend declaration shall be accessible in
// the scope of the class containing the friend declaration.
// PR12328
// Simple, non-templated case.
namespace test0 {
class X {
void f(); // expected-note {{implicitly declared private here}}
};
class Y {
friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test0::X'}}
};
}
// Templated but non-dependent.
namespace test1 {
class X {
void f(); // expected-note {{implicitly declared private here}}
};
template <class T> class Y {
friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test1::X'}}
};
}
// Dependent but instantiated at the right type.
namespace test2 {
template <class T> class Y;
class X {
void f();
friend class Y<int>;
};
template <class T> class Y {
friend void X::f();
};
template class Y<int>;
}
// Dependent and instantiated at the wrong type.
namespace test3 {
template <class T> class Y;
class X {
void f(); // expected-note {{implicitly declared private here}}
friend class Y<int>;
};
template <class T> class Y {
friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test3::X'}}
};
template class Y<float>; // expected-note {{in instantiation}}
}
// Dependent because dependently-scoped.
namespace test4 {
template <class T> class X {
void f();
};
template <class T> class Y {
friend void X<T>::f();
};
}
// Dependently-scoped, no friends.
namespace test5 {
template <class T> class X {
void f(); // expected-note {{implicitly declared private here}}
};
template <class T> class Y {
friend void X<T>::f(); // expected-error {{friend function 'f' is a private member of 'test5::X<int>'}}
};
template class Y<int>; // expected-note {{in instantiation}}
}
// Dependently-scoped, wrong friend.
namespace test6 {
template <class T> class Y;
template <class T> class X {
void f(); // expected-note {{implicitly declared private here}}
friend class Y<float>;
};
template <class T> class Y {
friend void X<T>::f(); // expected-error {{friend function 'f' is a private member of 'test6::X<int>'}}
};
template class Y<int>; // expected-note {{in instantiation}}
}
// Dependently-scoped, right friend.
namespace test7 {
template <class T> class Y;
template <class T> class X {
void f();
friend class Y<int>;
};
template <class T> class Y {
friend void X<T>::f();
};
template class Y<int>;
}