From: Chris Lattner Date: Fri, 21 Nov 2008 07:57:12 +0000 (+0000) Subject: merge 3 more diagnostics into 1. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=416e46febcb7084e715fbe0b9bf2cab7a85f5242;p=clang merge 3 more diagnostics into 1. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59805 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def index 99f24b9a4a..bb681e6986 100644 --- a/include/clang/Basic/DiagnosticKinds.def +++ b/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/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index f4a95f0531..cf1f01728d 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/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.