| 1 |
// Origin: PR c++/47398 |
| 2 |
// { dg-do compile } |
| 3 |
|
| 4 |
template<int> |
| 5 |
struct A |
| 6 |
{ |
| 7 |
typedef int INT; |
| 8 |
}; |
| 9 |
|
| 10 |
template<int I> |
| 11 |
struct transform |
| 12 |
{ |
| 13 |
static int bar(); |
| 14 |
}; |
| 15 |
|
| 16 |
template<class T, int a, class U, int b> |
| 17 |
struct B |
| 18 |
{ |
| 19 |
typedef typename A<a>::INT TINT; |
| 20 |
void baz(); |
| 21 |
}; |
| 22 |
|
| 23 |
template<class T, int a, class U> |
| 24 |
struct B<T, a, U, 1> |
| 25 |
{ |
| 26 |
typedef typename A<a>::INT TINT; |
| 27 |
void foo(); |
| 28 |
}; |
| 29 |
|
| 30 |
template<class T, int a, class U, int b> |
| 31 |
void |
| 32 |
B<T, a, U, b>::baz() |
| 33 |
{ |
| 34 |
int c = transform<sizeof(TINT)>::bar();//#0 |
| 35 |
} |
| 36 |
|
| 37 |
template<class T, int a, class U> |
| 38 |
void |
| 39 |
B<T, a, U, 1>::foo() |
| 40 |
{ |
| 41 |
int c = transform<sizeof(TINT)>::bar();//#1 |
| 42 |
} |
| 43 |
|
| 44 |
int |
| 45 |
main() |
| 46 |
{ |
| 47 |
B<int, 2, char, 1> i; |
| 48 |
i.foo(); |
| 49 |
// While instantiating |
| 50 |
// |
| 51 |
// template<class T, int a, class U> void B<T, a, U, 1>::foo() |
| 52 |
// |
| 53 |
// lookup_template_class resolves transform<sizeof(TINT)> in #1 to |
| 54 |
// the wrong one; it picks up the one in #0 instead. This is because |
| 55 |
// to compare the two A<a> comp_template_args uses cp_tree_equal |
| 56 |
// that fails to consider the number of siblings of parm 'a'. |
| 57 |
return 0; |
| 58 |
} |