From 23862f3d52080a15823a448ff2d9c98a9c6920c8 Mon Sep 17 00:00:00 2001 From: Eric Ludlam Date: Wed, 26 Nov 2014 14:27:10 -0500 Subject: [PATCH] Test friends * test/manual/cedet/cedet/semantic/tests/testfriends.cpp: (Af): Add a friend of C w/out the CLASS token. (C): New. (scA, scB, scC, scD): New test classes. (main): New (scA::PublicMethod, scB::b_pub_method, scC::c_pub_method) (scD::d_pub_method): New. --- .../cedet/semantic/tests/testfriends.cpp | 94 ++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/test/manual/cedet/cedet/semantic/tests/testfriends.cpp b/test/manual/cedet/cedet/semantic/tests/testfriends.cpp index f84ed5a2190..ff6e440a413 100644 --- a/test/manual/cedet/cedet/semantic/tests/testfriends.cpp +++ b/test/manual/cedet/cedet/semantic/tests/testfriends.cpp @@ -14,7 +14,9 @@ public: private: int privateVar; - friend class B; + friend class B; // Full class friend format. + + friend C; // Abbreviated friend format. }; @@ -26,6 +28,13 @@ public: }; +class C +{ +public: + int testC(); + int testAC(); + +}; int B::testB() { Af classA; @@ -35,3 +44,86 @@ int B::testB() { int B::testAB() { // %1% ( ( "testfriends.cpp" ) ( "B" "B::testAB" ) ) } + + +// Test friends when subclassing. +class scA : public scB, public scC, public scD +{ +public: + friend class scB; + friend scC; + +private: + + int data; + +public: + + int PublicMethod(); + +}; + +class scB +{ +public: + int b_pub_method(); +protected: + int b_prot_method(); +private: + int b_priv_method(); +}; + + +class scC +{ +public: + int c_pub_method(); +protected: + int c_prot_method(); +private: + int c_priv_method(); +}; + +class scD // Not a friend +{ +public: + int d_pub_method(); +protected: + int d_prot_method(); +private: + int d_priv_method(); +}; + + +int main() +{ + scA aclass; + + aclass. //-2- + ; //#2# ( "PublicMethod" "b_pub_method" "c_pub_method" "d_pub_method") +} + + +int scA::PublicMethod() { + this. // -3- + ; // #3# ( "PublicMethod" "b_prot_method" "b_pub_method" "c_prot_method" "c_pub_method" "d_prot_method" "d_pub_method" "data") +} + +int scB::b_pub_method() { + scA myfriend; + myfriend. // -4- + ; // #4# ( "PublicMethod" "b_priv_method" "b_prot_method" "b_pub_method" "c_pub_method" "d_pub_method" "data") +} + +int scC::c_pub_method() { + scA myfriend; + myfriend. // -5- + ; // #5# ( "PublicMethod" "b_pub_method" "c_priv_method" "c_prot_method" "c_pub_method" "d_pub_method" "data") +} + +int scD::d_pub_method() { + scA myfriend; + // The NOT FRIEND can't see 'data' which is private to scA + myfriend. // -6- + ; // #6# ( "PublicMethod" "b_pub_method" "c_pub_method" "d_priv_method" "d_prot_method" "d_pub_method") +} -- 2.39.2