From 4f962acf16b6dd26031be38c9fe2ac787fa2062e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 16 Aug 2011 20:16:33 +0200 Subject: [PATCH] Fixed #3009 (Using numeric constants in kernel space code) --- lib/checkother.cpp | 2 +- test/testincompletestatement.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 3086a48cc..9d0062dda 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3009,7 +3009,7 @@ 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% !!.")) { // bailout if there is a "? :" in this statement bool bailout = false; diff --git a/test/testincompletestatement.cpp b/test/testincompletestatement.cpp index a91278cc1..45d0e66da 100644 --- a/test/testincompletestatement.cpp +++ b/test/testincompletestatement.cpp @@ -69,6 +69,7 @@ private: TEST_CASE(conditionalcall); // ; 0==x ? X() : Y(); TEST_CASE(structinit); // #2462 : ABC abc{1,2,3}; TEST_CASE(returnstruct); + TEST_CASE(cast); // #3009 : (struct Foo *)123.a = 1; } void test1() @@ -201,6 +202,14 @@ private: "}"); ASSERT_EQUALS("", errout.str()); } + + void cast() + { + check("void f() {\n" + " ((struct foo *)(0x1234))->xy = 1;\n" + "}"); + ASSERT_EQUALS("", errout.str()); + } }; REGISTER_TEST(TestIncompleteStatement)