| 1 |
// C++ PR 70317 |
| 2 |
// { dg-do compile } |
| 3 |
// { dg-prune-output "expected primary-expression" } |
| 4 |
|
| 5 |
template<class T> class mytemplateclass |
| 6 |
{ |
| 7 |
public: |
| 8 |
template<class U> void class_func() {} |
| 9 |
template<class U> static void class_func_static() {} |
| 10 |
}; |
| 11 |
|
| 12 |
class myclass |
| 13 |
{ |
| 14 |
public: |
| 15 |
int testint; |
| 16 |
template<class U> void class_func() {} |
| 17 |
template<class U> static void class_func_static() {} |
| 18 |
}; |
| 19 |
|
| 20 |
template<class Y> void tests_func(mytemplateclass<Y> c, myclass c2) |
| 21 |
{ |
| 22 |
/* Dependent template accessors (ill-formed code). */ |
| 23 |
c.class_func<Y>(); // { dg-warning "keyword before dependent template name" } |
| 24 |
(&c)->class_func<Y>(); // { dg-warning "keyword before dependent template name" } |
| 25 |
mytemplateclass<Y>::class_func_static<Y>(); // { dg-warning "keyword before dependent template name" } |
| 26 |
|
| 27 |
/* Dependent template accessors (well-formed code). */ |
| 28 |
c.template class_func<Y>(); |
| 29 |
(&c)->template class_func<Y>(); |
| 30 |
mytemplateclass<Y>::template class_func_static<Y>(); |
| 31 |
|
| 32 |
/* Non-dependent template accessors (well-formed code). */ |
| 33 |
c2.class_func<myclass>(); |
| 34 |
(&c2)->class_func<myclass>(); |
| 35 |
myclass::class_func_static<myclass>(); |
| 36 |
} |
| 37 |
|
| 38 |
int main() |
| 39 |
{ |
| 40 |
mytemplateclass<myclass> c; |
| 41 |
myclass c2; |
| 42 |
tests_func<myclass>(c, c2); |
| 43 |
|
| 44 |
c2.testint = 53; |
| 45 |
/* Make sure this isn't treated as a template. */ |
| 46 |
bool testbool = c2.testint < 999 > 7; |
| 47 |
/* This probably will be treated as a template initially but it should still work. */ |
| 48 |
testbool = c2.testint < 123 > (50); |
| 49 |
} |