fix #2929 (Additional Unused variable check)

This commit is contained in:
Robert Reif 2011-07-21 18:37:37 -04:00
parent cc1ecccd01
commit c3c3eb74e8
2 changed files with 13 additions and 3 deletions

View File

@ -1912,7 +1912,6 @@ void CheckOther::functionVariableUsage()
tok = tok->tokAt(3);
variables.addVar(tok, Variables::standard, info,
tok->next()->str() == "=" || isStatic);
tok = tok->next();
}
// standard struct type declaration with possible initialization

View File

@ -99,7 +99,8 @@ private:
TEST_CASE(localvardynamic1);
TEST_CASE(localvardynamic2); // ticket #2904
TEST_CASE(localvararray1); // ticket #2780
TEST_CASE(localvarstring);
TEST_CASE(localvarstring1);
TEST_CASE(localvarstring2); // ticket #2929
// Don't give false positives for variables in structs/unions
TEST_CASE(localvarStruct1);
@ -2889,7 +2890,7 @@ private:
ASSERT_EQUALS("", errout.str());
}
void localvarstring() // ticket #1597
void localvarstring1() // ticket #1597
{
functionVariableUsage("void foo() {\n"
" std::string s;\n"
@ -2919,6 +2920,16 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
}
void localvarstring2() // ticket #2929
{
functionVariableUsage("void foo() {\n"
" std::string s;\n"
" int i;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:2]: (style) Unused variable: s\n"
"[test.cpp:3]: (style) Unused variable: i\n", errout.str());
}
};
REGISTER_TEST(TestUnusedVar)