diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index bbe081c39..8433b993c 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1837,6 +1837,8 @@ static bool valueFlowForward(Token * const startToken, it->intvalue += (inc ? 1 : -1); if (pre) setTokenValue(op, *it, settings); + const std::string info(tok2->str() + " is " + std::string(inc ? "incremented" : "decremented") + "', new value is " + it->infoString()); + it->errorPath.push_back(ErrorPathItem(tok2, info)); } } diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 8dd63229c..beb96ea80 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -1067,6 +1067,9 @@ private: "}"; ASSERT_EQUALS(false, testValueOfX(code, 4U, 9)); ASSERT_EQUALS(true, testValueOfX(code, 4U, 8)); + ASSERT_EQUALS("2,Assignment 'x=9', assigned value is 9\n" + "3,x is decremented', new value is 8\n", + getErrorPathForX(code, 4U)); code = "void x() {\n" " int x = value ? 6 : 0;\n"