fix #3066 (False positive: Inconclusive: Assigning address of local auto-variable to a function parameter.)
This commit is contained in:
parent
5bad978833
commit
833865e736
|
@ -118,7 +118,7 @@ void CheckAutoVariables::autoVariables()
|
|||
if (var1 && var1->isArgument() && Token::Match(var1->nameToken()->tokAt(-2), "%type% *"))
|
||||
{
|
||||
const Variable * var2 = symbolDatabase->getVariableFromVarId(tok->tokAt(6)->varId());
|
||||
if (var2 && var2->isLocal() && !var2->isStatic())
|
||||
if (var2 && var2->isLocal() && !var2->isStatic() && !Token::simpleMatch(var2->typeEndToken(), "*"))
|
||||
errorAutoVariableAssignment(tok->next(), _settings->inconclusive);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ private:
|
|||
TEST_CASE(testautovar4); // ticket #2928
|
||||
TEST_CASE(testautovar5); // ticket #2926
|
||||
TEST_CASE(testautovar6); // ticket #2931
|
||||
TEST_CASE(testautovar7); // ticket #3066
|
||||
TEST_CASE(testautovar_array1);
|
||||
TEST_CASE(testautovar_array2);
|
||||
TEST_CASE(testautovar_return1);
|
||||
|
@ -215,6 +216,17 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:4]: (error) Inconclusive: Assigning address of local auto-variable to a function parameter.\n", errout.str());
|
||||
}
|
||||
|
||||
void testautovar7() // ticket #3066
|
||||
{
|
||||
check("struct txt_scrollpane_s * TXT_NewScrollPane(struct txt_widget_s * target)\n"
|
||||
"{\n"
|
||||
" struct txt_scrollpane_s * scrollpane;\n"
|
||||
" target->parent = &scrollpane->widget;\n"
|
||||
" return scrollpane;\n"
|
||||
"}", false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void testautovar_array1()
|
||||
{
|
||||
check("void func1(int* arr[2])\n"
|
||||
|
|
Loading…
Reference in New Issue