FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.pt / inherit2.C
blob30cbebe1a1edf705c64d7fbd18dbf8b565a6812b
1 // Build don't link:
3 // Make sure we make the right unqualified class a friend
4 // See PR c++/4403
6 template <class T> struct A
8   struct AA;
9   struct AC;
12 template <class T> class B
13   :public A<T>
15   friend struct B::AA;          // OK, this has an implicit typename
16                                 // as if it is 'friend struct typename B::AA'
17                                 // (I think there's a defect report
18                                 // about that)
19   friend struct AC;     // this makes ::AC a friend *not* A<T>::AC
21   private: // only our friends can get out values
22   static T valueA_AA;
23   static T valueA_AC;
24   static T value_AC;
26 template <typename T> T B<T>::valueA_AA;
27 template <typename T> T B<T>::valueA_AC;// ERROR - private - XFAIL *-*-*
28 template <typename T> T B<T>::value_AC; // gets bogus error - XFAIL *-*-*
30 // this one is a friend
31 template <class T> struct A<T>::AA
33   int M ()
34   {
35     return B<T>::valueA_AA;
36   }
39 // this is not a friend
40 template <class T> struct A<T>::AC
42   T M ()
43   {
44     return B<T>::valueA_AC;     // ERROR - within this context - XFAIL *-*-*
45   }
48 // this is a friend
49 struct AC 
51   int M ()
52   {
53     return B<int>::value_AC;    // gets bogus error - XFAIL *-*-*
54   }
57 B<int> b;
58 A<int>::AA a_aa;
59 A<int>::AC a_ac;
60 AC ac;
62 int main ()
64   a_aa.M ();
65   a_ac.M ();
66   ac.M ();