diff --git a/lib/checkautovariables.cpp b/lib/checkautovariables.cpp index 27ae75c00..c4fc9b80f 100644 --- a/lib/checkautovariables.cpp +++ b/lib/checkautovariables.cpp @@ -401,6 +401,8 @@ static bool astHasAutoResult(const Token *tok) return false; if (tok->isOp()) { + if (tok->tokType() == Token::eIncDecOp) + return false; if ((tok->str() == "<<" || tok->str() == ">>") && tok->astOperand1()) { const Token* tok2 = tok->astOperand1(); while (tok2 && tok2->str() == "*" && !tok2->astOperand2()) diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index 6b340b5e9..2865989e7 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -1022,6 +1022,11 @@ private: " return \"foo\" + str;\n" "}"); ASSERT_EQUALS("", errout.str()); + + check("int& incValue(int& value) {\n" + " return ++value;\n" + "}"); + ASSERT_EQUALS("", errout.str()); } void returnReferenceLambda() {