File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4429,7 +4429,7 @@ void CheckOther::checkModuloOfOne()
44294429 for (const Token *tok = mTokenizer ->tokens (); tok; tok = tok->next ()) {
44304430 if (!tok->astOperand2 () || !tok->astOperand1 ())
44314431 continue ;
4432- if (tok->str () != " %" )
4432+ if (tok->str () != " %" && tok-> str () != " %= " )
44334433 continue ;
44344434 if (!tok->valueType () || !tok->valueType ()->isIntegral ())
44354435 continue ;
Original file line number Diff line number Diff line change @@ -13284,6 +13284,13 @@ class TestOther : public TestFixture {
1328413284 " if (j % c) {}\n"
1328513285 "}\n");
1328613286 ASSERT_EQUALS("", errout_str());
13287+
13288+ check("void f() {\n"
13289+ " int i = 0;\n"
13290+ " i %= 1;\n"
13291+ " (void)i;\n"
13292+ "}\n");
13293+ ASSERT_EQUALS("[test.cpp:3:7]: (style) Modulo of one is always equal to zero [moduloofone]\n", errout_str());
1328713294 }
1328813295
1328913296 void sameExpressionPointers() {
You can’t perform that action at this time.
0 commit comments