Fixed #783 (Refactoring: autoVariables error message is hard coded in 3 locations)
http://sourceforge.net/apps/trac/cppcheck/ticket/783
This commit is contained in:
parent
29e7261529
commit
3c5b13a276
|
@ -196,18 +196,12 @@ void CheckAutoVariables::autoVariables()
|
|||
//Critical assignement
|
||||
else if (Token::Match(tok, "[;{}] %var% = & %var%") && errorAv(tok->tokAt(1), tok->tokAt(4)))
|
||||
{
|
||||
reportError(tok,
|
||||
Severity::error,
|
||||
"autoVariables",
|
||||
"Wrong assignement of an auto-variable to an effective parameter of a function");
|
||||
errorAutoVariableAssignment(tok);
|
||||
}
|
||||
//Critical assignement
|
||||
else if (Token::Match(tok, "[;{}] %var% [ %any% ] = & %var%") && errorAv(tok->tokAt(1), tok->tokAt(7)))
|
||||
{
|
||||
reportError(tok,
|
||||
Severity::error,
|
||||
"autoVariables",
|
||||
"Wrong assignement of an auto-variable to an effective parameter of a function");
|
||||
errorAutoVariableAssignment(tok);
|
||||
}
|
||||
// Critical return
|
||||
else if (Token::Match(tok, "return & %var% ;") && isAutoVar(tok->tokAt(2)->varId()))
|
||||
|
@ -304,5 +298,8 @@ void CheckAutoVariables::errorReturnPointerToLocalArray(const Token *tok)
|
|||
reportError(tok, Severity::error, "returnLocalVariable", "Returning pointer to local array variable");
|
||||
}
|
||||
|
||||
|
||||
void CheckAutoVariables::errorAutoVariableAssignment(const Token *tok)
|
||||
{
|
||||
reportError(tok, Severity::error, "autoVariables", "Wrong assignement of an auto-variable to an effective parameter of a function");
|
||||
}
|
||||
|
||||
|
|
|
@ -69,11 +69,12 @@ private:
|
|||
|
||||
|
||||
void errorReturnPointerToLocalArray(const Token *tok);
|
||||
void errorAutoVariableAssignment(const Token *tok);
|
||||
|
||||
|
||||
void getErrorMessages()
|
||||
{
|
||||
reportError(0, Severity::error, "autoVariables", "Wrong assignement of an auto-variable to an effective parameter of a function");
|
||||
errorAutoVariableAssignment(0);
|
||||
errorReturnPointerToLocalArray(0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue