Fixed #2655 (false positive: (warning) Redundant code: Found a statement that begins with numeric constant)

This commit is contained in:
Daniel Marjamäki 2011-03-30 21:57:01 +02:00
parent 97328f08de
commit b8cda19ca6
2 changed files with 13 additions and 0 deletions

View File

@ -2767,7 +2767,11 @@ void CheckOther::checkIncompleteStatement()
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
{
if (tok->str() == "(")
{
tok = tok->link();
if (Token::simpleMatch(tok, ") {") && Token::simpleMatch(tok->next()->link(), "} ;"))
tok = tok->next()->link();
}
else if (Token::simpleMatch(tok, "= {"))
tok = tok->next()->link();

View File

@ -68,6 +68,7 @@ private:
TEST_CASE(structarray);
TEST_CASE(conditionalcall); // ; 0==x ? X() : Y();
TEST_CASE(structinit); // #2462 : ABC abc{1,2,3};
TEST_CASE(returnstruct);
}
void test1()
@ -192,6 +193,14 @@ private:
check("struct A {};");
ASSERT_EQUALS("", errout.str());
}
void returnstruct()
{
check("struct s foo() {\n"
" return (struct s){0,0};\n"
"}");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestIncompleteStatement)