diff options
-rw-r--r-- | clang/include/clang/Basic/DiagnosticKinds.def | 9 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 11 |
2 files changed, 9 insertions, 11 deletions
diff --git a/clang/include/clang/Basic/DiagnosticKinds.def b/clang/include/clang/Basic/DiagnosticKinds.def index 99f24b9a4a4..bb681e69865 100644 --- a/clang/include/clang/Basic/DiagnosticKinds.def +++ b/clang/include/clang/Basic/DiagnosticKinds.def @@ -1351,12 +1351,9 @@ DIAG(err_operator_overload_static, ERROR, "overloaded '%0' cannot be a static member function") DIAG(err_operator_overload_default_arg, ERROR, "parameter of overloaded '%0' cannot have a default argument") -DIAG(err_operator_overload_must_be_unaryx, ERROR, - "overloaded '%0' must be a unary operator (has %1 parameter%s1)") -DIAG(err_operator_overload_must_be_binaryx, ERROR, - "overloaded '%0' must be a binary operator (has %1 parameter%s1)") -DIAG(err_operator_overload_must_be_unary_or_binaryx, ERROR, - "overloaded '%0' must be a unary or binary operator (has %1 parameter%s1)") +DIAG(err_operator_overload_must_be, ERROR, + "overloaded '%0' must be a %select{unary|binary|unary or binary}2 operator" + " (has %1 parameter%s1)") DIAG(err_operator_overload_must_be_member, ERROR, "overloaded '%0' must be a non-static member function") DIAG(err_operator_overload_post_incdec_must_be_int, ERROR, diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index f4a95f05319..cf1f01728d2 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -1872,18 +1872,19 @@ bool Sema::CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl) { (NumParams == 2 && !CanBeBinaryOperator) || (NumParams < 1) || (NumParams > 2))) { // We have the wrong number of parameters. - diag::kind DK; + unsigned ErrorKind; if (CanBeUnaryOperator && CanBeBinaryOperator) { - DK = diag::err_operator_overload_must_be_unary_or_binaryx; + ErrorKind = 2; // 2 -> unary or binary. } else if (CanBeUnaryOperator) { - DK = diag::err_operator_overload_must_be_unaryx; + ErrorKind = 0; // 0 -> unary } else { assert(CanBeBinaryOperator && "All non-call overloaded operators are unary or binary!"); - DK = diag::err_operator_overload_must_be_binaryx; + ErrorKind = 1; // 1 -> binary } - return Diag(FnDecl->getLocation(), DK) << FnDecl->getName() << NumParams; + return Diag(FnDecl->getLocation(), diag::err_operator_overload_must_be) + << FnDecl->getName() << NumParams << ErrorKind; } // Overloaded operators other than operator() cannot be variadic. |