diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 6856b57c3..f558effd9 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1868,7 +1868,11 @@ void CheckOther::checkIncompleteStatement() else if (tok->str() == "{" && Token::Match(tok->tokAt(-2), "%type% %var%")) tok = tok->link(); - else if (Token::Match(tok, "[;{}] %str%") || Token::Match(tok, "[;{}] %num% !!.")) { + else if (Token::Match(tok, "[;{}] %str%") || Token::Match(tok, "[;{}] %num%")) { + // No warning if numeric constant is followed by a "." or "," + if (Token::Match(tok->next(), "%num% [,.]")) + continue; + // bailout if there is a "? :" in this statement bool bailout = false; for (const Token *tok2 = tok->tokAt(2); tok2; tok2 = tok2->next()) { diff --git a/test/testincompletestatement.cpp b/test/testincompletestatement.cpp index e6dbbf18d..a930e421b 100644 --- a/test/testincompletestatement.cpp +++ b/test/testincompletestatement.cpp @@ -67,6 +67,7 @@ private: TEST_CASE(structinit); // #2462 : ABC abc{1,2,3}; TEST_CASE(returnstruct); TEST_CASE(cast); // #3009 : (struct Foo *)123.a = 1; + TEST_CASE(increment); // #3251 : FP for increment } void test1() { @@ -194,6 +195,14 @@ private: "}"); ASSERT_EQUALS("", errout.str()); } + + void increment() { + check("void f() {\n" + " int x = 1;\n" + " x++, x++;\n" + "}"); + ASSERT_EQUALS("", errout.str()); + } }; REGISTER_TEST(TestIncompleteStatement)