[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / CXX / class.access / class.friend / p9-cxx0x.cpp
blobf748a2bb3ba6ec2cdeb027c25f5a5c6251225204
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 // C++98 [class.friend]p7:
4 // C++11 [class.friend]p9:
5 // A name nominated by a friend declaration shall be accessible in
6 // the scope of the class containing the friend declaration.
8 // PR12328
9 // Simple, non-templated case.
10 namespace test0 {
11 class X {
12 void f(); // expected-note {{implicitly declared private here}}
15 class Y {
16 friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test0::X'}}
20 // Templated but non-dependent.
21 namespace test1 {
22 class X {
23 void f(); // expected-note {{implicitly declared private here}}
26 template <class T> class Y {
27 friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test1::X'}}
31 // Dependent but instantiated at the right type.
32 namespace test2 {
33 template <class T> class Y;
35 class X {
36 void f();
37 friend class Y<int>;
40 template <class T> class Y {
41 friend void X::f();
44 template class Y<int>;
47 // Dependent and instantiated at the wrong type.
48 namespace test3 {
49 template <class T> class Y;
51 class X {
52 void f(); // expected-note {{implicitly declared private here}}
53 friend class Y<int>;
56 template <class T> class Y {
57 friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test3::X'}}
60 template class Y<float>; // expected-note {{in instantiation}}
63 // Dependent because dependently-scoped.
64 namespace test4 {
65 template <class T> class X {
66 void f();
69 template <class T> class Y {
70 friend void X<T>::f();
74 // Dependently-scoped, no friends.
75 namespace test5 {
76 template <class T> class X {
77 void f(); // expected-note {{implicitly declared private here}}
80 template <class T> class Y {
81 friend void X<T>::f(); // expected-error {{friend function 'f' is a private member of 'test5::X<int>'}}
84 template class Y<int>; // expected-note {{in instantiation}}
87 // Dependently-scoped, wrong friend.
88 namespace test6 {
89 template <class T> class Y;
91 template <class T> class X {
92 void f(); // expected-note {{implicitly declared private here}}
93 friend class Y<float>;
96 template <class T> class Y {
97 friend void X<T>::f(); // expected-error {{friend function 'f' is a private member of 'test6::X<int>'}}
100 template class Y<int>; // expected-note {{in instantiation}}
103 // Dependently-scoped, right friend.
104 namespace test7 {
105 template <class T> class Y;
107 template <class T> class X {
108 void f();
109 friend class Y<int>;
112 template <class T> class Y {
113 friend void X<T>::f();
116 template class Y<int>;