1// { dg-do run } 2// Testcase for implicit 'typename' and resolution of 'typename's in the 3// current scope. 4 5class base1 { 6public: 7 int bar() const 8 { return 1; } 9}; 10 11class base2 { 12public: 13 int bar() const 14 { return 0; } 15}; 16 17template<class X> 18struct base_trait { 19 typedef base1 base; 20}; 21 22template<> 23struct base_trait<float> { 24 typedef base2 base; 25}; 26 27template<class T> 28class weird : public base_trait<T>::base { 29public: 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 39template <class T> 40typename 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 48template <class T> 49int typename weird<T>::base::* weird<T>::g () 50{ return 0; } 51#endif 52 53int main() 54{ 55 weird<float> z; 56 return z.zowee() || z.f().bar(); 57} 58