Fixed ticket 205 (False positive: char variable used in bit operation)

This commit is contained in:
Daniel Marjamäki 2009-03-23 19:04:51 +01:00
parent 06776c6ac7
commit 44c952873e
2 changed files with 14 additions and 0 deletions

View File

@ -712,6 +712,9 @@ void CheckOther::CheckCharVariable()
break;
}
else if (tok2->str() == "return")
continue;
std::string temp = "%var% [ " + tok->str() + " ]";
if ((tok2->str() != ".") && Token::Match(tok2->next(), temp.c_str()))
{

View File

@ -39,6 +39,7 @@ private:
TEST_CASE(array_index);
TEST_CASE(bitop1);
TEST_CASE(bitop2);
TEST_CASE(return1);
}
void check(const char code[])
@ -108,6 +109,16 @@ private:
"}\n");
ASSERT_EQUALS(std::string(""), errout.str());
}
void return1()
{
check("void foo()\n"
"{\n"
" char c;\n"
" return &c;\n"
"}\n");
ASSERT_EQUALS(std::string(""), errout.str());
}
};
REGISTER_TEST(TestCharVar)