1 // { dg-do run  }
2 // Testcase for implicit 'typename' and resolution of 'typename's in the
3 // current scope.
4 
5 class base1 {
6 public:
bar()7     int bar() const
8     { return 1; }
9 };
10 
11 class base2 {
12 public:
bar()13     int bar() const
14     { return 0; }
15 };
16 
17 template<class X>
18 struct base_trait {
19     typedef base1 base;
20 };
21 
22 template<>
23 struct base_trait<float> {
24     typedef base2 base;
25 };
26 
27 template<class T>
28 class weird : public base_trait<T>::base {
29 public:
30     typedef typename base_trait<T>::base base;
31 
32     base f ();
33     int base::* g ();
34 
35     int zowee() const
36     { return this->bar(); }
37 };
38 
39 template <class T>
40 typename weird<T>::base weird<T>::f ()
41 {
42     return base();
43 }
44 
45 // The standard does not allow this case; the `typename' keyword may
46 // not appear in a ptr-operator.
47 #if 0
48 template <class T>
49 int typename weird<T>::base::* weird<T>::g ()
50 { return 0; }
51 #endif
52 
53 int main()
54 {
55     weird<float> z;
56     return z.zowee() || z.f().bar();
57 }
58