This commit is contained in:
Alexander Mai 2014-04-23 20:50:48 +02:00
commit 5c98e4d039
2 changed files with 11 additions and 1 deletions

View File

@ -2197,7 +2197,7 @@ void CheckOther::checkIncompleteStatement()
// no warning if this is the last statement in a ({})
for (const Token *tok2 = tok->next(); tok2; tok2 = tok2->next()) {
if (tok2->str() == "(")
tok2 = tok->link();
tok2 = tok2->link();
else if (Token::Match(tok2, "[;{}]")) {
bailout = Token::simpleMatch(tok2, "; } )");
break;

View File

@ -59,6 +59,7 @@ private:
TEST_CASE(test3);
TEST_CASE(test4);
TEST_CASE(test5);
TEST_CASE(test6);
TEST_CASE(test_numeric);
TEST_CASE(intarray);
TEST_CASE(structarraynull);
@ -123,6 +124,15 @@ private:
ASSERT_EQUALS("[test.cpp:3]: (warning) Redundant code: Found a statement that begins with numeric constant.\n", errout.str());
}
void test6() {
// dont crash
check("void f() {\n"
" 1 == (two + three);\n"
" 2 != (two + three);\n"
" (one + two) != (two + three);\n"
"}");
}
void test_numeric() {
check("struct P\n"
"{\n"