diff --git a/src/cppcheck.cpp b/src/cppcheck.cpp index 58736be0c..d76760173 100644 --- a/src/cppcheck.cpp +++ b/src/cppcheck.cpp @@ -389,7 +389,7 @@ void CppCheck::checkFile(const std::string &code, const char FileName[]) checkOther.CheckStructMemberUsage(); // Check if a constant function parameter is passed by value - if (ErrorMessage::passedByValue()) + if (ErrorMessage::passedByValue(_settings)) checkOther.CheckConstantFunctionParameter(); // Variable scope (check if the scope could be limited) diff --git a/src/errormessage.h b/src/errormessage.h index 9ba44e9ce..c251e965a 100644 --- a/src/errormessage.h +++ b/src/errormessage.h @@ -251,9 +251,9 @@ public: { return msg1(tokenizer, Location) + "Function parameter '" + parname + "' is passed by value. It could be passed by reference instead."; } - static bool passedByValue() + static bool passedByValue(const Settings &s) { - return true; + return s._checkCodingStyle; } static std::string constStatement(const Tokenizer *tokenizer, const Token *Location, const std::string &type) diff --git a/tools/errmsg.cpp b/tools/errmsg.cpp index f6073e6ff..4adb0d60d 100644 --- a/tools/errmsg.cpp +++ b/tools/errmsg.cpp @@ -86,7 +86,7 @@ int main() err.push_back(Message("udivError", Message::always, "Unsigned division. The result will be wrong.")); err.push_back(Message("udivWarning", Message::style_all, "Warning: Division with signed and unsigned operators")); err.push_back(Message("unusedStructMember", Message::style, "struct or union member '%1::%2' is never used", "structname", "varname")); - err.push_back(Message("passedByValue", Message::always, "Function parameter '%1' is passed by value. It could be passed by reference instead.", "parname")); + err.push_back(Message("passedByValue", Message::style, "Function parameter '%1' is passed by value. It could be passed by reference instead.", "parname")); err.push_back(Message("constStatement", Message::style, "Redundant code: Found a statement that begins with %1 constant", "type")); err.push_back(Message("charArrayIndex", Message::style, "Warning - using char variable as array index")); err.push_back(Message("charBitOp", Message::style, "Warning - using char variable in bit operation"));