Fixed false positive #6575

This commit is contained in:
PKEuS 2015-03-11 20:25:27 +01:00
parent c8bee3e1a6
commit 9bafa3bf25
2 changed files with 13 additions and 0 deletions

View File

@ -1420,6 +1420,8 @@ const Token *Token::getValueTokenDeadPointer() const
const Variable * const var = vartok->variable();
if (var->isStatic() || var->isReference())
continue;
if (var->scope()->type == Scope::eUnion && var->scope()->nestedIn == this->scope())
continue;
// variable must be in same function (not in subfunction)
if (functionscope != getfunctionscope(var->scope()))
continue;

View File

@ -3912,6 +3912,17 @@ private:
" dosth();\n"
"}");
ASSERT_EQUALS("[test.cpp:7]: (error) Dead pointer usage. Pointer 'former_hover' is dead if it has been assigned '&item' at line 5.\n", errout.str());
// #6575
checkDeadPointer("void trp_deliver_signal() {\n"
" union {\n"
" Uint32 theData[25];\n"
" EventReport repData;\n"
" };\n"
" EventReport * rep = &repData;\n"
" rep->setEventType(NDB_LE_Connected);\n"
"}");
ASSERT_EQUALS("", errout.str());
}
};