Merge from mainline
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.law / visibility2.C
blob42d267368ce5dc324a977b547f0c51405f34dac1
1 // { dg-do assemble  }
2 // GROUPS passed visibility
3 #include <iostream>
7 class base {
8 //==========
10     void base_priv(const char * n)              
11         { std::cout << "base_priv called from: " << n << "\n";  };
13 protected:
15     void base_prot(const char * n) 
16         { std::cout << "base_prot called from: " << n << "\n"; };
18 public:
20     void base_publ(const char * n) 
21         { std::cout << "base_publ called from: " << n << "\n"; };
23     void test(const char * n) { base_publ(n); base_prot(n); base_priv(n); }
25 }; // class base
29 class derived : public base {   // Make this public, 
30 //============================  // and we don't get an error
32 friend void derived_friend();
34 public :
36     void test(const char * n) { base_publ(n); base_prot(n);}
38 }; // class derived
42 void
43 derived_friend()
44 //--------------
46     derived pd;
48     pd.base_publ("friend of derived class");    // Compiler error here
49     pd.base_prot("friend of derived class");
54 int main(int argc, char *argv[])
55 //==========================
57     base b;
58     b.base_publ("base class object");
59     b.test("member of base class object");
60     std::cout << "\n";
62     derived pd;
63     pd.test("member of derived class object");
64     derived_friend();
65     std::cout << "\n";
67 } /* main */