File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -333,10 +333,13 @@ void CheckBool::checkAssignBoolToPointer()
333333 const Scope * scope = symbolDatabase->functionScopes [i];
334334 for (const Token* tok = scope->classStart ; tok != scope->classEnd ; tok = tok->next ()) {
335335 if (Token::Match (tok, " %var% = %bool% ;" )) {
336- // Todo: properly check if there is a deref
336+ // check if there is a deref
337337 // *x.p = true; // <- don't warn
338338 // x.p = true; // <- warn
339- if (Token::Match (tok->previous (), " [*.)]" ))
339+ const Token *prev = tok;
340+ while (Token::Match (prev->tokAt (-2 ), " %var% ." ))
341+ prev = prev->tokAt (-2 );
342+ if (Token::Match (prev->previous (), " [*.)]" ))
340343 continue ;
341344
342345 // Is variable a pointer?
Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ class TestBool : public TestFixture {
111111 " S s = {0};\n "
112112 " s.p = true;\n "
113113 " }\n " );
114- TODO_ASSERT_EQUALS ( " error" , " " , errout.str ());
114+ ASSERT_EQUALS ( " [test.cpp:6]: ( error) Boolean value assigned to pointer. \n " , errout.str ());
115115 }
116116
117117 void comparisonOfBoolExpressionWithInt1 () {
You can’t perform that action at this time.
0 commit comments