From 44c952873ef6fc12e9f03c6ae6d8501b888004c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 23 Mar 2009 19:04:51 +0100 Subject: [PATCH] Fixed ticket 205 (False positive: char variable used in bit operation) --- src/checkother.cpp | 3 +++ test/testcharvar.cpp | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/checkother.cpp b/src/checkother.cpp index 15544da28..d93eb515e 100644 --- a/src/checkother.cpp +++ b/src/checkother.cpp @@ -712,6 +712,9 @@ void CheckOther::CheckCharVariable() break; } + else if (tok2->str() == "return") + continue; + std::string temp = "%var% [ " + tok->str() + " ]"; if ((tok2->str() != ".") && Token::Match(tok2->next(), temp.c_str())) { diff --git a/test/testcharvar.cpp b/test/testcharvar.cpp index cd304d1d8..8cde41664 100644 --- a/test/testcharvar.cpp +++ b/test/testcharvar.cpp @@ -39,6 +39,7 @@ private: TEST_CASE(array_index); TEST_CASE(bitop1); TEST_CASE(bitop2); + TEST_CASE(return1); } void check(const char code[]) @@ -108,6 +109,16 @@ private: "}\n"); ASSERT_EQUALS(std::string(""), errout.str()); } + + void return1() + { + check("void foo()\n" + "{\n" + " char c;\n" + " return &c;\n" + "}\n"); + ASSERT_EQUALS(std::string(""), errout.str()); + } }; REGISTER_TEST(TestCharVar)