gcc/testsuite/g++.dg/template/typename26.C
raw| 1 | // Example 4 from [temp.res.general]/3. |
| 2 | |
| 3 | struct A { |
| 4 | struct X { }; |
| 5 | int X; |
| 6 | }; |
| 7 | struct B { |
| 8 | struct X { }; |
| 9 | }; |
| 10 | template<class T> void f(T t) { |
| 11 | typename T::X x; // { dg-error "'int A::X', which is not a type" } |
| 12 | } |
| 13 | void foo() { |
| 14 | A a; |
| 15 | B b; |
| 16 | f(b); // OK, T::X refers to B::X |
| 17 | f(a); // error: T::X refers to the data member A::X not the struct A::X |
| 18 | // { dg-message "required from here" "" { target *-*-* } .-1 } |
| 19 | } |