fix #2765 (Non local address detected as address of local auto-variable)
This commit is contained in:
parent
ccb831d375
commit
bb5dfa58a1
|
@ -53,7 +53,7 @@ bool CheckAutoVariables::isAutoVar(unsigned int varId)
|
|||
{
|
||||
const Variable *var = _tokenizer->getSymbolDatabase()->getVariableFromVarId(varId);
|
||||
|
||||
if (!var || !var->isLocal() || var->isStatic() || var->isArray())
|
||||
if (!var || !var->isLocal() || var->isStatic() || var->isArray() || var->typeEndToken()->str() == "*")
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -75,7 +75,8 @@ private:
|
|||
TEST_CASE(testautovar_return2);
|
||||
TEST_CASE(testautovar_extern);
|
||||
TEST_CASE(testinvaliddealloc);
|
||||
TEST_CASE(testassign); // Ticket #1819
|
||||
TEST_CASE(testassign1); // Ticket #1819
|
||||
TEST_CASE(testassign2); // Ticket #2765
|
||||
|
||||
TEST_CASE(returnLocalVariable1);
|
||||
TEST_CASE(returnLocalVariable2);
|
||||
|
@ -230,7 +231,7 @@ private:
|
|||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
}
|
||||
|
||||
void testassign()
|
||||
void testassign1() // Ticket #1819
|
||||
{
|
||||
check("void f(EventPtr *eventP, ActionPtr **actionsP) {\n"
|
||||
" EventPtr event = *eventP;\n"
|
||||
|
@ -239,6 +240,15 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void testassign2() // Ticket #2765
|
||||
{
|
||||
check("static void function(unsigned long **datap) {\n"
|
||||
" struct my_s *mr = global_structure_pointer;\n"
|
||||
" *datap = &mr->value;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void returnLocalVariable1()
|
||||
{
|
||||
check("char *foo()\n"
|
||||
|
|
Loading…
Reference in New Issue