fix line number in messagex for CheckAutoVariables::autoVariables

This commit is contained in:
Robert Reif 2011-09-01 20:34:31 -04:00
parent f4e07c3179
commit 5bad978833
2 changed files with 10 additions and 10 deletions

View File

@ -107,7 +107,7 @@ void CheckAutoVariables::autoVariables()
{
const Variable * var = symbolDatabase->getVariableFromVarId(tok->tokAt(5)->varId());
if (var && (!var->isClass() || var->type()))
errorAutoVariableAssignment(tok, false);
errorAutoVariableAssignment(tok->next(), false);
}
else if (Token::Match(tok, "[;{}] %var% . %var% = & %var%"))
{
@ -119,7 +119,7 @@ void CheckAutoVariables::autoVariables()
{
const Variable * var2 = symbolDatabase->getVariableFromVarId(tok->tokAt(6)->varId());
if (var2 && var2->isLocal() && !var2->isStatic())
errorAutoVariableAssignment(tok, _settings->inconclusive);
errorAutoVariableAssignment(tok->next(), _settings->inconclusive);
}
}
tok = tok->tokAt(6);
@ -134,7 +134,7 @@ void CheckAutoVariables::autoVariables()
{
const Variable * var2 = symbolDatabase->getVariableFromVarId(tok->tokAt(5)->varId());
if (var2 && var2->isLocal() && var2->isArray() && !var2->isStatic())
errorAutoVariableAssignment(tok, _settings->inconclusive);
errorAutoVariableAssignment(tok->next(), _settings->inconclusive);
}
}
tok = tok->tokAt(5);
@ -146,13 +146,13 @@ void CheckAutoVariables::autoVariables()
{
const Variable * var2 = symbolDatabase->getVariableFromVarId(tok->tokAt(4)->varId());
if (var2 && var2->isLocal() && var2->isArray() && !var2->isStatic())
errorAutoVariableAssignment(tok, false);
errorAutoVariableAssignment(tok->next(), false);
}
tok = tok->tokAt(4);
}
else if (Token::Match(tok, "[;{}] %var% [ %any% ] = & %var%") && errorAv(tok->tokAt(1), tok->tokAt(7)))
{
errorAutoVariableAssignment(tok, false);
errorAutoVariableAssignment(tok->next(), false);
}
// Critical return
else if (Token::Match(tok, "return & %var% ;") && isAutoVar(tok->tokAt(2)->varId()))

View File

@ -111,7 +111,7 @@ private:
" int num = 2;\n"
" *res = #\n"
"}");
ASSERT_EQUALS("[test.cpp:3]: (error) Assigning address of local auto-variable to a function parameter.\n", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Assigning address of local auto-variable to a function parameter.\n", errout.str());
check("void func1(int **res)\n"
"{\n"
@ -138,7 +138,7 @@ private:
" int num = 2;\n"
" *res = #\n"
"}");
ASSERT_EQUALS("[test.cpp:6]: (error) Assigning address of local auto-variable to a function parameter.\n", errout.str());
ASSERT_EQUALS("[test.cpp:7]: (error) Assigning address of local auto-variable to a function parameter.\n", errout.str());
check("class Fred {\n"
" void func1(int **res);\n"
@ -168,7 +168,7 @@ private:
" int x[100];\n"
" *p = x;\n"
"}");
ASSERT_EQUALS("[test.cpp:3]: (error) Assigning address of local auto-variable to a function parameter.\n", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Assigning address of local auto-variable to a function parameter.\n", errout.str());
}
void testautovar4() // ticket #2928
@ -195,7 +195,7 @@ private:
" char a;\n"
" ab->a = &a;\n"
"}", true);
ASSERT_EQUALS("[test.cpp:3]: (error) Inconclusive: Assigning address of local auto-variable to a function parameter.\n", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Inconclusive: Assigning address of local auto-variable to a function parameter.\n", errout.str());
}
void testautovar6() // ticket #2931
@ -212,7 +212,7 @@ private:
" char a[10];\n"
" x->str = a;\n"
"}", true);
ASSERT_EQUALS("[test.cpp:3]: (error) Inconclusive: Assigning address of local auto-variable to a function parameter.\n", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Inconclusive: Assigning address of local auto-variable to a function parameter.\n", errout.str());
}
void testautovar_array1()