From b8ee500d45827e3ce3fdcb5e05b68f5cc597bafa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 3 Jun 2017 15:31:29 +0200 Subject: [PATCH] Fixed #7092 (Invalid style error: Variable not assigned a value) --- lib/checkunusedvar.cpp | 2 +- test/testunusedvar.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp index cca6c1c4f..eb51fa5c2 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -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) == "*") diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index dc665ce55..152ed1855 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -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"