File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,6 +95,8 @@ void CheckBool::checkBitwiseOnBoolean()
9595 for (const Token* tok = scope->bodyStart ->next (); tok != scope->bodyEnd ; tok = tok->next ()) {
9696 if (tok->isBinaryOp () && (tok->str () == " &" || tok->str () == " |" )) {
9797 if (astIsBool (tok->astOperand1 ()) || astIsBool (tok->astOperand2 ())) {
98+ if (tok->astOperand2 ()->variable () && tok->astOperand2 ()->variable ()->nameToken () == tok->astOperand2 ())
99+ continue ;
98100 const std::string expression = astIsBool (tok->astOperand1 ()) ? tok->astOperand1 ()->expressionString () : tok->astOperand2 ()->expressionString ();
99101 bitwiseOnBooleanError (tok, expression, tok->str () == " &" ? " &&" : " ||" );
100102 }
Original file line number Diff line number Diff line change @@ -858,6 +858,11 @@ class TestBool : public TestFixture {
858858 " foo(bar, &b);\n "
859859 " }" );
860860 ASSERT_EQUALS (" " , errout.str ());
861+
862+ check (" void f(bool b) {\n " // #9405
863+ " class C { void foo(bool &b) {} };\n "
864+ " }" );
865+ ASSERT_EQUALS (" " , errout.str ());
861866 }
862867
863868 void incrementBoolean () {
You can’t perform that action at this time.
0 commit comments