| 1 |
// PR c++/22173 |
| 2 |
|
| 3 |
struct A |
| 4 |
{ |
| 5 |
static void a1(); |
| 6 |
template <typename T> |
| 7 |
static void b1(T); |
| 8 |
template <int I> |
| 9 |
struct B { |
| 10 |
static void b1(); |
| 11 |
template <typename T> |
| 12 |
static void b2(T); |
| 13 |
}; |
| 14 |
struct C { |
| 15 |
static void c1(); |
| 16 |
}; |
| 17 |
}; |
| 18 |
|
| 19 |
template<int I> void f1() |
| 20 |
{ |
| 21 |
A* p; |
| 22 |
A::template a1(); // { dg-error "template" } |
| 23 |
A::template b1(0); |
| 24 |
p->template a1(); // { dg-error "template" } |
| 25 |
p->template b1('a'); |
| 26 |
|
| 27 |
A::template B<0>::b1(); |
| 28 |
A::template B<0>::template b1(); // { dg-error "template" } |
| 29 |
A::template B<0>::template b2(0); |
| 30 |
A::template B<0>::template b2<double>(0); |
| 31 |
|
| 32 |
// Because B<I> is dependent, none of these are errors, as this |
| 33 |
// function is not instantiated. |
| 34 |
A::template B<I>::b1(); |
| 35 |
A::template B<I>::template b1(); |
| 36 |
A::template B<I>::template b2(0); |
| 37 |
A::template B<I>::template b2<double>(0); |
| 38 |
|
| 39 |
A::template C::c1(); // { dg-error "template" } |
| 40 |
} |
| 41 |
|
| 42 |
template<int I> void f2() |
| 43 |
{ |
| 44 |
// These are copies of lines from f1, but this function is |
| 45 |
// instantiated, so we should get errors here. |
| 46 |
A::template B<I>::b1(); |
| 47 |
A::template B<I>::template b1(); // { dg-error "template" } |
| 48 |
A::template B<I>::template b2(0); |
| 49 |
A::template B<I>::template b2<double>(0); |
| 50 |
} |
| 51 |
|
| 52 |
template void f2<0>(); // { dg-message "required" } |