fix regression #1819 (False positive: auto variable assignment (unseen typedef))

This commit is contained in:
Robert Reif 2011-05-06 18:18:48 -04:00
parent 3629f953f0
commit ccb831d375
2 changed files with 4 additions and 2 deletions

View File

@ -97,7 +97,9 @@ void CheckAutoVariables::autoVariables()
//Critical assignment
if (Token::Match(tok, "[;{}] * %var% = & %var%") && errorAv(tok->tokAt(2), tok->tokAt(5)))
{
errorAutoVariableAssignment(tok);
const Variable * var = symbolDatabase->getVariableFromVarId(tok->tokAt(5)->varId());
if (var && (!var->isClass() || var->type()))
errorAutoVariableAssignment(tok);
}
else if (Token::Match(tok, "[;{}] %var% [ %any% ] = & %var%") && errorAv(tok->tokAt(1), tok->tokAt(7)))
{

View File

@ -236,7 +236,7 @@ private:
" EventPtr event = *eventP;\n"
" *actionsP = &event->actions;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:2]: (error) Assigning address of local auto-variable to a function parameter.\n", errout.str());
ASSERT_EQUALS("", errout.str());
}
void returnLocalVariable1()