Auto Variables: Reverted fix for #1514 because my idea was wrong. See ticket: #2944

This commit is contained in:
Daniel Marjamäki 2011-07-27 10:43:44 +02:00
parent 5cb701d3c1
commit 2b48c7624c
2 changed files with 2 additions and 24 deletions

View File

@ -134,17 +134,6 @@ void CheckAutoVariables::autoVariables()
}
tok = tok->tokAt(4);
}
else if (Token::Match(tok, "[;{}] %var% = & %var% ;"))
{
const Variable * var1 = symbolDatabase->getVariableFromVarId(tok->tokAt(1)->varId());
if (var1 && var1->isArgument() && Token::Match(var1->nameToken()->tokAt(-2), "%type% *"))
{
const Variable * var2 = symbolDatabase->getVariableFromVarId(tok->tokAt(4)->varId());
if (var2 && var2->isLocal() && !var2->isStatic())
errorAutoVariableAssignment(tok);
}
tok = tok->tokAt(4);
}
else if (Token::Match(tok, "[;{}] %var% [ %any% ] = & %var%") && errorAv(tok->tokAt(1), tok->tokAt(7)))
{
errorAutoVariableAssignment(tok);

View File

@ -72,8 +72,7 @@ private:
TEST_CASE(testautovar3); // ticket #2925
TEST_CASE(testautovar4); // ticket #2928
TEST_CASE(testautovar5); // ticket #2926
TEST_CASE(testautovar6); // ticket #1514
TEST_CASE(testautovar7); // ticket #2931
TEST_CASE(testautovar6); // ticket #2931
TEST_CASE(testautovar_array1);
TEST_CASE(testautovar_array2);
TEST_CASE(testautovar_return1);
@ -188,17 +187,7 @@ private:
ASSERT_EQUALS("[test.cpp:3]: (error) Assigning address of local auto-variable to a function parameter.\n", errout.str());
}
void testautovar6() // ticket #1514
{
check("void foo(int * x)\n"
"{\n"
" int y;\n"
" x = &y;\n"
"}");
ASSERT_EQUALS("[test.cpp:3]: (error) Assigning address of local auto-variable to a function parameter.\n", errout.str());
}
void testautovar7() // ticket #2931
void testautovar6() // ticket #2931
{
check("void foo(struct X *x)\n"
"{\n"