Fixed #6327 (Unwanted constStatement on (void)0)

This commit is contained in:
Daniel Marjamäki 2014-12-21 13:42:21 +01:00
parent 1c8c8e45d0
commit 293dc1efc7
2 changed files with 10 additions and 0 deletions

View File

@ -1717,6 +1717,10 @@ void CheckOther::checkIncompleteStatement()
if (Token::Match(tok->next(), "%num% [,.]"))
continue;
// No warning for [;{}] 0 ;
if (Token::Match(tok, "[;{}] 0 ;"))
continue;
// bailout if there is a "? :" in this statement
bool bailout = false;
for (const Token *tok2 = tok->tokAt(2); tok2; tok2 = tok2->next()) {

View File

@ -61,6 +61,7 @@ private:
TEST_CASE(test5);
TEST_CASE(test6);
TEST_CASE(test_numeric);
TEST_CASE(void0); // #6327: No fp for statement "(void)0;"
TEST_CASE(intarray);
TEST_CASE(structarraynull);
TEST_CASE(structarray);
@ -150,6 +151,11 @@ private:
ASSERT_EQUALS("", errout.str());
}
void void0() { // #6327
check("void f() { 0; }");
ASSERT_EQUALS("", errout.str());
}
void intarray() {
check("int arr[] = { 100/2, 1*100 };");
ASSERT_EQUALS("", errout.str());