| 1 |
// PR c++/104319 |
| 2 |
// { dg-do compile } |
| 3 |
// { dg-options "" } |
| 4 |
|
| 5 |
template<typename T> struct A {}; |
| 6 |
template<typename T> int z; // { dg-warning "variable templates only available with" "" { target c++11_down } } |
| 7 |
template<int N> int w; // { dg-warning "variable templates only available with" "" { target c++11_down } } |
| 8 |
|
| 9 |
void |
| 10 |
foo () |
| 11 |
{ |
| 12 |
z<int>=0; // { dg-error "'>=' should be '> =' to terminate a template argument list" } |
| 13 |
} // { dg-error "expected ';' before numeric constant" "" { target *-*-* } .-1 } |
| 14 |
|
| 15 |
int |
| 16 |
bar () |
| 17 |
{ |
| 18 |
return z<int>>0; // { dg-error "spurious '>>', use '>' to terminate a template argument list" "" { target c++98_only } } |
| 19 |
} // { dg-error "expected ';' before numeric constant" "" { target c++98_only } .-1 } |
| 20 |
|
| 21 |
int |
| 22 |
baz () |
| 23 |
{ |
| 24 |
return z<int>>=0; // { dg-error "'>>=' should be '> >=' to terminate a template argument list" } |
| 25 |
} // { dg-error "expected ';' before numeric constant" "" { target *-*-* } .-1 } |
| 26 |
|
| 27 |
int |
| 28 |
qux () |
| 29 |
{ |
| 30 |
return z<A<int>>=0; // { dg-error "'>>=' should be '>> =' to terminate a template argument list" "" { target c++11 } } |
| 31 |
} // { dg-error "'>>=' should be '> > =' to terminate a template argument list" "" { target c++98_only } .-1 } |
| 32 |
// { dg-error "template argument 1 is invalid" "" { target *-*-* } .-2 } |
| 33 |
|
| 34 |
void |
| 35 |
quux () |
| 36 |
{ |
| 37 |
w<5>=0>=6>=8> = 5; |
| 38 |
} |
| 39 |
|
| 40 |
#if __cplusplus >= 201103L |
| 41 |
struct B { constexpr bool operator >= (int) { return true; } }; |
| 42 |
|
| 43 |
void |
| 44 |
corge () |
| 45 |
{ |
| 46 |
w<B()>=5> = 5; |
| 47 |
} |
| 48 |
#endif |