diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 3115e4434..1be6b6e3e 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1385,6 +1385,9 @@ static bool canBeConst(const Variable *var) if (!argVar|| (!argVar->isConst() && argVar->isReference())) return false; } + } else if (parent->str() == "&" && !parent->astOperand2()) { + // TODO: check how pointer is used + return false; } else if (parent->isConstOp()) ; else if (parent->isAssignmentOp()) { diff --git a/test/testother.cpp b/test/testother.cpp index 83babd60b..1e74974cb 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1557,6 +1557,12 @@ private: "}"); ASSERT_EQUALS("", errout.str()); + check("void foo(std::string* str);\n" + "void f(std::string str) {\n" + " foo(&str);\n" + "}"); + ASSERT_EQUALS("", errout.str()); + check("void foo(int& i1, const std::string& str, int& i2);\n" "void f(std::string str) {\n" " foo((a+b)*c, str, x);\n"