OSDN Git Service

* lib/g++-dg.exp (g++-dg-test): Add "repo" option.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.pt / inherit2.C
1 // { dg-do assemble  }
2
3 // Make sure we make the right unqualified class a friend
4 // See PR c++/4403
5
6 template <class T> struct A
7 {
8   struct AA;
9   struct AC;
10 };
11
12 template <class T> class B
13   :public A<T>
14 {
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
20
21   private: // only our friends can get out values
22   static T valueA_AA;
23   static T valueA_AC;
24   static T value_AC;
25 };
26 template <typename T> T B<T>::valueA_AA;
27 template <typename T> T B<T>::valueA_AC;// { dg-error "" "" { xfail *-*-* } } private - 
28 template <typename T> T B<T>::value_AC; // { dg-bogus "" "" { xfail *-*-* } }  - 
29
30 // this one is a friend
31 template <class T> struct A<T>::AA
32 {
33   int M ()
34   {
35     return B<T>::valueA_AA;
36   }
37 };
38
39 // this is not a friend
40 template <class T> struct A<T>::AC
41 {
42   T M ()
43   {
44     return B<T>::valueA_AC;     // { dg-error "" "" { xfail *-*-* } } within this context - 
45   }
46 };
47
48 // this is a friend
49 struct AC 
50 {
51   int M ()
52   {
53     return B<int>::value_AC;    // { dg-bogus "" "" { xfail *-*-* } }  - 
54   }
55 };
56
57 B<int> b;
58 A<int>::AA a_aa;
59 A<int>::AC a_ac;
60 AC ac;
61
62 int main ()
63 {
64   a_aa.M ();
65   a_ac.M ();
66   ac.M ();
67 }