Ticket #6954: Properly handle pointers to arrays in CheckUnunsedVar.

This commit is contained in:
Simon Martin 2015-08-27 23:56:26 +02:00
parent 436d7b6d59
commit c78d99dc07
2 changed files with 10 additions and 0 deletions

View File

@ -689,6 +689,8 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
type = Variables::reference;
else if (i->nameToken()->previous()->str() == "*" && i->nameToken()->strAt(-2) == "*")
type = Variables::pointerPointer;
else if (i->isPointerToArray())
type = Variables::pointerPointer;
else if (i->isPointer())
type = Variables::pointer;
else if (_tokenizer->isC() ||

View File

@ -91,6 +91,7 @@ private:
TEST_CASE(localvar45); // ticket #4899
TEST_CASE(localvar46); // ticket #5491 (C++11 style initialization)
TEST_CASE(localvar47); // ticket #6603
TEST_CASE(localvar48); // ticket #6954
TEST_CASE(localvaralias1);
TEST_CASE(localvaralias2); // ticket #1637
TEST_CASE(localvaralias3); // ticket #1639
@ -1894,6 +1895,13 @@ private:
ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'retrieveCount' is assigned a value that is never used.\n", errout.str());
}
void localvar48() { // #6954
functionVariableUsage("void foo() {\n"
" long (*pKoeff)[256] = new long[9][256];\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void localvaralias1() {
functionVariableUsage("void foo()\n"
"{\n"