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

This commit is contained in:
Daniel Marjamäki 2011-01-19 18:37:33 +01:00
parent 94aafa482c
commit ecac93ebed
2 changed files with 12 additions and 0 deletions

View File

@ -2365,6 +2365,9 @@ void CheckOther::checkIncompleteStatement()
else if (Token::simpleMatch(tok, "= {"))
tok = tok->next()->link();
else if (tok->str() == "{" && Token::Match(tok->tokAt(-2), "%type% %var%"))
tok = tok->link();
else if (Token::Match(tok, "[;{}] %str%") || Token::Match(tok, "[;{}] %num%"))
{
// bailout if there is a "? :" in this statement

View File

@ -67,6 +67,7 @@ private:
TEST_CASE(structarraynull);
TEST_CASE(structarray);
TEST_CASE(conditionalcall); // ; 0==x ? X() : Y();
TEST_CASE(structinit); // #2462 : ABC abc{1,2,3};
}
void test1()
@ -178,6 +179,14 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
}
void structinit()
{
check("void f() {\n"
" ABC abc{1,2,3};\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestIncompleteStatement)