Fix false positive 'passedByValue' when address of argument is used
This commit is contained in:
parent
db6f4f4a3b
commit
655a8b21b6
|
@ -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()) {
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue