File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1794,7 +1794,7 @@ void CheckOther::checkCharVariable()
17941794
17951795 else if (Token::Match (tok, " [;{}] %var% = %any% [&^|] ( * %var% ) ;" )) {
17961796 const Variable* var = symbolDatabase->getVariableFromVarId (tok->tokAt (7 )->varId ());
1797- if (!var || !var->isPointer ())
1797+ if (!var || !var->isPointer () || ! Token::Match (var-> typeStartToken (), " static| const| char " ) )
17981798 continue ;
17991799 // it's ok with a bitwise and where the other operand is 0xff or less..
18001800 if (tok->strAt (4 ) == " &" && tok->tokAt (3 )->isNumber () && MathLib::isGreater (" 0x100" , tok->strAt (3 )))
Original file line number Diff line number Diff line change @@ -204,6 +204,14 @@ class TestCharVar : public TestFixture {
204204 " return ret;\n "
205205 " }" );
206206 ASSERT_EQUALS (" " , errout.str ());
207+
208+ // #3872 - false positive
209+ check (" int f(int *p) {\n "
210+ " int ret = a();\n "
211+ " ret |= *p;\n "
212+ " return ret;\n "
213+ " }" );
214+ ASSERT_EQUALS (" " , errout.str ());
207215 }
208216};
209217
You can’t perform that action at this time.
0 commit comments