assign function parameters: only show warning when --enable=warning or --enable=style is used. Ticket: #2930
This commit is contained in:
parent
082c48d557
commit
6bb8dd605a
|
@ -94,6 +94,8 @@ void CheckAutoVariables::autoVariables()
|
|||
{
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
||||
const bool reportWarnings(_settings->isEnabled("warning"));
|
||||
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
for (std::size_t i = 0; i < functions; ++i) {
|
||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
||||
|
@ -107,7 +109,8 @@ void CheckAutoVariables::autoVariables()
|
|||
const Variable * var = tok->tokAt(5)->variable();
|
||||
if (checkRvalueExpression(var, tok->tokAt(6)))
|
||||
errorAutoVariableAssignment(tok->next(), false);
|
||||
} else if (Token::Match(tok, "[;{}] %var% =") &&
|
||||
} else if (reportWarnings &&
|
||||
Token::Match(tok, "[;{}] %var% =") &&
|
||||
isPtrArg(tok->next()) &&
|
||||
Token::Match(tok->next()->variable()->typeStartToken(), "struct| %type% * %var% [,)]") &&
|
||||
!pointerIsDereferencedInScope(tok->next()->variable(), scope)) {
|
||||
|
|
|
@ -75,6 +75,7 @@ std::string Settings::addEnabled(const std::string &str)
|
|||
|
||||
static std::set<std::string> id;
|
||||
if (id.empty()) {
|
||||
id.insert("warning");
|
||||
id.insert("style");
|
||||
id.insert("performance");
|
||||
id.insert("portability");
|
||||
|
|
|
@ -40,6 +40,7 @@ private:
|
|||
|
||||
Settings settings;
|
||||
settings.inconclusive = inconclusive;
|
||||
settings.addEnabled("warning");
|
||||
|
||||
// Tokenize..
|
||||
Tokenizer tokenizer(&settings, this);
|
||||
|
|
Loading…
Reference in New Issue