From 293dc1efc79d9622ac855031d5c866f3d36fcc73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 21 Dec 2014 13:42:21 +0100 Subject: [PATCH] Fixed #6327 (Unwanted constStatement on (void)0) --- lib/checkother.cpp | 4 ++++ test/testincompletestatement.cpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 2869baaa4..dc97baa05 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -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()) { diff --git a/test/testincompletestatement.cpp b/test/testincompletestatement.cpp index d15b281d3..f1b43f223 100644 --- a/test/testincompletestatement.cpp +++ b/test/testincompletestatement.cpp @@ -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());