"non-type template argument does not refer to an object or function">;
def err_template_arg_not_pointer_to_member_form : Error<
"non-type template argument is not a pointer to member constant">;
-def err_template_arg_extra_parens : Error<
- "non-type template argument cannot be surrounded by parentheses">;
+def ext_template_arg_extra_parens : ExtWarn<
+ "address non-type template argument cannot be surrounded by parentheses">;
def err_pointer_to_member_type : Error<
"invalid use of pointer to member type after %select{.*|->*}0">;
// corresponding template-parameter is a reference; or
DeclRefExpr *DRE = 0;
- // Ignore (and complain about) any excess parentheses.
+ // In C++98/03 mode, give an extension warning on any extra parentheses.
+ // See http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#773
+ bool ExtraParens = false;
while (ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
- if (!Invalid) {
+ if (!Invalid && !ExtraParens && !S.getLangOptions().CPlusPlus0x) {
S.Diag(Arg->getSourceRange().getBegin(),
- diag::err_template_arg_extra_parens)
+ diag::ext_template_arg_extra_parens)
<< Arg->getSourceRange();
- Invalid = true;
+ ExtraParens = true;
}
Arg = Parens->getSubExpr();
// -- a pointer to member expressed as described in 5.3.1.
DeclRefExpr *DRE = 0;
- // Ignore (and complain about) any excess parentheses.
+ // In C++98/03 mode, give an extension warning on any extra parentheses.
+ // See http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#773
+ bool ExtraParens = false;
while (ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
- if (!Invalid) {
+ if (!Invalid && !ExtraParens && !getLangOptions().CPlusPlus0x) {
Diag(Arg->getSourceRange().getBegin(),
- diag::err_template_arg_extra_parens)
+ diag::ext_template_arg_extra_parens)
<< Arg->getSourceRange();
- Invalid = true;
+ ExtraParens = true;
}
Arg = Parens->getSubExpr();
A7<&Z::int_member> *a18_1;
A7c<&Z::int_member> *a18_2;
A7<&Z::float_member> *a18_3; // expected-error{{non-type template argument of type 'float Z::*' cannot be converted to a value of type 'int Z::*'}}
-A7c<(&Z::int_member)> *a18_3; // expected-error{{non-type template argument cannot be surrounded by parentheses}}
+A7c<(&Z::int_member)> *a18_4; // expected-warning{{address non-type template argument cannot be surrounded by parentheses}}
template<unsigned char C> struct Overflow; // expected-note{{template parameter is declared here}}