noExplicitConstructor - Verbose error message edit (#5260)
The goal is to use keywords like "converting constructor" and "implicit conversion" that will help users further study what this warning is about. I think that the old message provided no context to the uninitiated.
This commit is contained in:
parent
bfaa7c075a
commit
e7a2585e0a
|
@ -1067,7 +1067,7 @@ void CheckClass::noConstructorError(const Token *tok, const std::string &classna
|
|||
void CheckClass::noExplicitConstructorError(const Token *tok, const std::string &classname, bool isStruct)
|
||||
{
|
||||
const std::string message(std::string(isStruct ? "Struct" : "Class") + " '$symbol' has a constructor with 1 argument that is not explicit.");
|
||||
const std::string verbose(message + " Such constructors should in general be explicit for type safety reasons. Using the explicit keyword in the constructor means some mistakes when using the class can be avoided.");
|
||||
const std::string verbose(message + " Such, so called \"Converting constructors\", should in general be explicit for type safety reasons as that prevents unintended implicit conversions.");
|
||||
reportError(tok, Severity::style, "noExplicitConstructor", "$symbol:" + classname + '\n' + message + '\n' + verbose, CWE398, Certainty::normal);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue