File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -681,7 +681,7 @@ void CheckOther::checkRedundantAssignment()
681681 // Is there a redundant assignment?
682682 const Token *start;
683683 if (tok->isAssignmentOp ())
684- start = tok->next ();
684+ start = tok->astOperand2 ();
685685 else
686686 start = tok->findExpressionStartEndTokens ().second ->next ();
687687
Original file line number Diff line number Diff line change @@ -11032,6 +11032,15 @@ class TestOther : public TestFixture {
1103211032 " a = x;\n"
1103311033 "}\n");
1103411034 ASSERT_EQUALS("", errout_str());
11035+
11036+ check("int f(int a, int b, int c) {\n" // #4491
11037+ " int x = a + b;\n"
11038+ " if (c)\n"
11039+ " x = a + b;\n"
11040+ " return x;\n"
11041+ "}\n");
11042+ ASSERT_EQUALS("[test.cpp:2:11] -> [test.cpp:4:9]: (style) Variable 'x' is assigned an expression that holds the same value. [redundantAssignment]\n",
11043+ errout_str());
1103511044 }
1103611045
1103711046 void varFuncNullUB() { // #4482
You can’t perform that action at this time.
0 commit comments