Fixed #7092 (Invalid style error: Variable not assigned a value)

This commit is contained in:
Daniel Marjamäki 2017-06-03 15:31:29 +02:00
parent ccb2f2ce6a
commit b8ee500d45
2 changed files with 10 additions and 1 deletions

View File

@ -718,7 +718,7 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
else if (i->isArray() && i->nameToken()->previous()->str() == "&")
type = Variables::referenceArray;
else if (i->isArray())
type = Variables::array;
type = (i->dimensions().size() == 1U) ? Variables::array : Variables::pointerArray;
else if (i->isReference())
type = Variables::reference;
else if (i->nameToken()->previous()->str() == "*" && i->nameToken()->strAt(-2) == "*")

View File

@ -125,6 +125,7 @@ private:
TEST_CASE(localvararray2); // ticket #3438
TEST_CASE(localvararray3); // ticket #3980
TEST_CASE(localvararray4); // ticket #4839
TEST_CASE(localvararray5); // ticket #7092
TEST_CASE(localvarstring1);
TEST_CASE(localvarstring2); // ticket #2929
TEST_CASE(localvarconst1);
@ -3726,6 +3727,14 @@ private:
ASSERT_EQUALS("", errout.str());
}
void localvararray5() {
functionVariableUsage("int foo() {\n"
" int p[5][5];\n"
" dostuff(*p);\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void localvarstring1() { // ticket #1597
functionVariableUsage("void foo() {\n"
" std::string s;\n"