Simplify error messages for two-parameter overloaded increment/decrement operators

llvm-svn: 59442
This commit is contained in:
Douglas Gregor 2008-11-17 15:03:30 +00:00
parent 77324f3854
commit 9edcc802c3
3 changed files with 6 additions and 17 deletions

View File

@ -1346,12 +1346,8 @@ DIAG(err_operator_overload_must_be_unary_or_binary_plural, ERROR,
DIAG(err_operator_overload_must_be_member, ERROR,
"overloaded operator '%0' must be a non-static member function")
DIAG(err_operator_overload_post_inc_must_be_int, ERROR,
"second parameter of overloaded post-increment operator must have type 'int' (not '%0')")
DIAG(err_operator_overload_post_dec_must_be_int, ERROR,
"second parameter of overloaded post-decrement operator must have type 'int' (not '%0')")
DIAG(err_operator_overload_post_inc_must_be_int_member, ERROR,
"parameter of overloaded post-increment operator must have type 'int' (not '%0')")
DIAG(err_operator_overload_post_dec_must_be_int_member, ERROR,
DIAG(err_operator_overload_post_dec_must_be_int, ERROR,
"parameter of overloaded post-decrement operator must have type 'int' (not '%0')")
DIAG(err_operator_missing_type_specifier, ERROR,
"missing type specifier after 'operator'")

View File

@ -1987,17 +1987,10 @@ bool Sema::CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl) {
if (!ParamIsInt) {
diag::kind DK;
if (Op == OO_PlusPlus) {
if (MethodDecl)
DK = diag::err_operator_overload_post_inc_must_be_int_member;
else
DK = diag::err_operator_overload_post_inc_must_be_int;
} else {
if (MethodDecl)
DK = diag::err_operator_overload_post_dec_must_be_int_member;
else
DK = diag::err_operator_overload_post_dec_must_be_int;
}
if (Op == OO_PlusPlus)
DK = diag::err_operator_overload_post_inc_must_be_int;
else
DK = diag::err_operator_overload_post_dec_must_be_int;
Diag(LastParam->getLocation(), DK,
Context.getCanonicalType(LastParam->getType()).getAsString(),
SourceRange(FnDecl->getLocation()));

View File

@ -34,4 +34,4 @@ typedef int INT;
typedef float FLOAT;
Y& operator++(Y&);
Y operator++(Y&, INT);
X operator++(X&, FLOAT); // expected-error{{second parameter of overloaded post-increment operator must have type 'int' (not 'float')}}
X operator++(X&, FLOAT); // expected-error{{parameter of overloaded post-increment operator must have type 'int' (not 'float')}}