diff --git a/src/checkautovariables.cpp b/src/checkautovariables.cpp index 17ad2ca99..51864f05c 100644 --- a/src/checkautovariables.cpp +++ b/src/checkautovariables.cpp @@ -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"); +} diff --git a/src/checkautovariables.h b/src/checkautovariables.h index 4cdec71ec..9a4f341d5 100644 --- a/src/checkautovariables.h +++ b/src/checkautovariables.h @@ -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); }