diff options
Diffstat (limited to 'test/CXX/class.access')
-rw-r--r-- | test/CXX/class.access/class.friend/p1.cpp | 34 | ||||
-rw-r--r-- | test/CXX/class.access/class.friend/p11.cpp | 80 | ||||
-rw-r--r-- | test/CXX/class.access/class.friend/p3-cxx0x.cpp | 13 | ||||
-rw-r--r-- | test/CXX/class.access/class.friend/p6.cpp | 4 | ||||
-rw-r--r-- | test/CXX/class.access/p4.cpp | 10 | ||||
-rw-r--r-- | test/CXX/class.access/p6.cpp | 4 |
6 files changed, 118 insertions, 27 deletions
diff --git a/test/CXX/class.access/class.friend/p1.cpp b/test/CXX/class.access/class.friend/p1.cpp index 19d94cf..4a68162 100644 --- a/test/CXX/class.access/class.friend/p1.cpp +++ b/test/CXX/class.access/class.friend/p1.cpp @@ -7,8 +7,8 @@ // special access rights to the friends, but they do not make the nominated // friends members of the befriending class. -struct S { static void f(); }; -S* g() { return 0; } +struct S { static void f(); }; // expected-note 2 {{'S' declared here}} +S* g() { return 0; } // expected-note 2 {{'g' declared here}} struct X { friend struct S; @@ -19,8 +19,8 @@ void test1() { S s; g()->f(); S::f(); - X::g(); // expected-error{{no member named 'g' in 'X'}} - X::S x_s; // expected-error{{no type named 'S' in 'X'}} + X::g(); // expected-error{{no member named 'g' in 'X'; did you mean simply 'g'?}} + X::S x_s; // expected-error{{no type named 'S' in 'X'; did you mean simply 'S'?}} X x; x.g(); // expected-error{{no member named 'g' in 'X'}} } @@ -36,24 +36,24 @@ namespace N { friend struct S2* g2(); }; - struct S2 { static void f2(); }; - S2* g2() { return 0; } + struct S2 { static void f2(); }; // expected-note 2 {{'S2' declared here}} + S2* g2() { return 0; } // expected-note 2 {{'g2' declared here}} void test() { g()->f(); S s; S::f(); - X::g(); // expected-error{{no member named 'g' in 'N::X'}} - X::S x_s; // expected-error{{no type named 'S' in 'N::X'}} + X::g(); // expected-error{{no member named 'g' in 'N::X'; did you mean simply 'g'?}} + X::S x_s; // expected-error{{no type named 'S' in 'N::X'; did you mean simply 'S'?}} X x; x.g(); // expected-error{{no member named 'g' in 'N::X'}} g2(); S2 s2; - ::g2(); // expected-error{{no member named 'g2' in the global namespace}} - ::S2 g_s2; // expected-error{{no type named 'S2' in the global namespace}} - X::g2(); // expected-error{{no member named 'g2' in 'N::X'}} - X::S2 x_s2; // expected-error{{no type named 'S2' in 'N::X'}} + ::g2(); // expected-error{{no member named 'g2' in the global namespace; did you mean simply 'g2'?}} + ::S2 g_s2; // expected-error{{no type named 'S2' in the global namespace; did you mean simply 'S2'?}} + X::g2(); // expected-error{{no member named 'g2' in 'N::X'; did you mean simply 'g2'?}} + X::S2 x_s2; // expected-error{{no type named 'S2' in 'N::X'; did you mean simply 'S2'?}} x.g2(); // expected-error{{no member named 'g2' in 'N::X'}} } } @@ -287,22 +287,22 @@ namespace test9 { // PR7230 namespace test10 { - extern "C" void f(void); - extern "C" void g(void); + extern "C" void test10_f(void); + extern "C" void test10_g(void); namespace NS { class C { void foo(void); // expected-note {{declared private here}} - friend void test10::f(void); + friend void test10::test10_f(void); }; static C* bar; } - void f(void) { + void test10_f(void) { NS::bar->foo(); } - void g(void) { + void test10_g(void) { NS::bar->foo(); // expected-error {{private member}} } } diff --git a/test/CXX/class.access/class.friend/p11.cpp b/test/CXX/class.access/class.friend/p11.cpp index a05b2d2..ba44a0d 100644 --- a/test/CXX/class.access/class.friend/p11.cpp +++ b/test/CXX/class.access/class.friend/p11.cpp @@ -17,3 +17,83 @@ namespace test1 { }; } } + +namespace test2 { + void bar(); // expected-note {{'::test2::bar' declared here}} + + void foo() { // expected-note {{'::test2::foo' declared here}} + struct S1 { + friend void foo(); // expected-error {{no matching function 'foo' found in local scope; did you mean '::test2::foo'?}} + }; + + void foo(); // expected-note {{local declaration nearly matches}} + struct S2 { + friend void foo(); + }; + + { + struct S2 { + friend void foo(); // expected-error {{no matching function found in local scope}} + }; + } + + { + int foo; + struct S3 { + friend void foo(); // expected-error {{no matching function found in local scope}} + }; + } + + struct S4 { + friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}} + }; + + { void bar(); } + struct S5 { + friend void bar(); // expected-error {{no matching function found in local scope}} + }; + + { + void bar(); + struct S6 { + friend void bar(); + }; + } + + struct S7 { + void bar() { Inner::f(); } + struct Inner { + friend void bar(); + static void f() {} + }; + }; + + void bar(); // expected-note {{'bar' declared here}} + struct S8 { + struct Inner { + friend void bar(); + }; + }; + + struct S9 { + struct Inner { + friend void baz(); // expected-error {{no matching function 'baz' found in local scope; did you mean 'bar'?}} + }; + }; + + struct S10 { + void quux() {} + void foo() { + struct Inner1 { + friend void bar(); // expected-error {{no matching function found in local scope}} + friend void quux(); // expected-error {{no matching function found in local scope}} + }; + + void bar(); + struct Inner2 { + friend void bar(); + }; + } + }; + } +} diff --git a/test/CXX/class.access/class.friend/p3-cxx0x.cpp b/test/CXX/class.access/class.friend/p3-cxx0x.cpp index ea9d2ce..5a1ab49 100644 --- a/test/CXX/class.access/class.friend/p3-cxx0x.cpp +++ b/test/CXX/class.access/class.friend/p3-cxx0x.cpp @@ -36,10 +36,17 @@ class A { public: class foo {}; static int y; - template <typename S> friend class B<S>::ty; + template <typename S> friend class B<S>::ty; // expected-warning {{dependent nested name specifier 'B<S>::' for friend class declaration is not supported}} }; -template <typename T> class B { typedef int ty; }; +template<typename T> class B { typedef int ty; }; + +template<> class B<int> { + class ty { + static int f(A<int> &a) { return a.y; } // ok, befriended + }; +}; +int f(A<char> &a) { return a.y; } // FIXME: should be an error struct { // Ill-formed @@ -56,7 +63,7 @@ struct { friend float; - template<typename T> friend class A<T>::foo; + template<typename T> friend class A<T>::foo; // expected-warning {{not supported}} } a; void testA() { (void)sizeof(A<int>); } diff --git a/test/CXX/class.access/class.friend/p6.cpp b/test/CXX/class.access/class.friend/p6.cpp index 7f7d909..2fe20fe 100644 --- a/test/CXX/class.access/class.friend/p6.cpp +++ b/test/CXX/class.access/class.friend/p6.cpp @@ -11,6 +11,10 @@ struct Y { friend void X::f2() { } // expected-error{{friend function definition cannot be qualified with 'X::'}} }; +template <typename T> struct Z { + friend void T::f() {} // expected-error{{friend function definition cannot be qualified with 'T::'}} +}; + void local() { void f(); diff --git a/test/CXX/class.access/p4.cpp b/test/CXX/class.access/p4.cpp index 5ad738b..0564a52 100644 --- a/test/CXX/class.access/p4.cpp +++ b/test/CXX/class.access/p4.cpp @@ -151,7 +151,7 @@ namespace test3 { virtual Base3 {}; Derived3 d3; // expected-note {{implicit default constructor}}\ - // expected-note{{implicit default destructor}}} + // expected-note{{implicit destructor}}} } // Conversion functions. @@ -207,13 +207,13 @@ namespace test5 { class Test1 { A a; }; // expected-error {{private member}} void test1() { Test1 a; - a = Test1(); // expected-note{{implicit default copy}} + a = Test1(); // expected-note{{implicit copy}} } class Test2 : A {}; // expected-error {{private member}} void test2() { Test2 a; - a = Test2(); // expected-note{{implicit default copy}} + a = Test2(); // expected-note{{implicit copy}} } } @@ -226,12 +226,12 @@ namespace test6 { class Test1 { A a; }; // expected-error {{field of type 'test6::A' has private copy constructor}} void test1(const Test1 &t) { - Test1 a = t; // expected-note{{implicit default copy}} + Test1 a = t; // expected-note{{implicit copy}} } class Test2 : A {}; // expected-error {{base class 'test6::A' has private copy constructor}} void test2(const Test2 &t) { - Test2 a = t; // expected-note{{implicit default copy}} + Test2 a = t; // expected-note{{implicit copy}} } } diff --git a/test/CXX/class.access/p6.cpp b/test/CXX/class.access/p6.cpp index fbdc87b..6a93658 100644 --- a/test/CXX/class.access/p6.cpp +++ b/test/CXX/class.access/p6.cpp @@ -92,7 +92,7 @@ namespace test3 { template <class T> class Outer::A<T, typename T::nature> { public: - static void foo(); + static void foo(); // expected-note {{'Outer::A<B, Green>::foo' declared here}} }; class B { @@ -102,7 +102,7 @@ namespace test3 { void test() { Outer::A<B, Green>::foo(); - Outer::A<B, Blue>::foo(); // expected-error {{no member named 'foo'}} + Outer::A<B, Blue>::foo(); // expected-error {{no member named 'foo' in 'test3::Outer::A<test3::B, test3::Blue>'; did you mean 'Outer::A<B, Green>::foo'?}} } } |