parent
3836367d95
commit
4d72e0f5b5
|
@ -1548,8 +1548,11 @@ void CheckOther::checkConstPointer()
|
||||||
const Token* const gparent = parent->astParent();
|
const Token* const gparent = parent->astParent();
|
||||||
if (Token::Match(gparent, "%cop%") && !gparent->isUnaryOp("&") && !gparent->isUnaryOp("*"))
|
if (Token::Match(gparent, "%cop%") && !gparent->isUnaryOp("&") && !gparent->isUnaryOp("*"))
|
||||||
continue;
|
continue;
|
||||||
if (Token::simpleMatch(gparent, "return"))
|
if (Token::simpleMatch(gparent, "return")) {
|
||||||
|
const Function* function = gparent->scope()->function;
|
||||||
|
if (function && (!Function::returnsReference(function) || Function::returnsConst(function)))
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
else if (Token::Match(gparent, "%assign%") && parent == gparent->astOperand2()) {
|
else if (Token::Match(gparent, "%assign%") && parent == gparent->astOperand2()) {
|
||||||
bool takingRef = false, nonConstPtrAssignment = false;
|
bool takingRef = false, nonConstPtrAssignment = false;
|
||||||
const Token *lhs = gparent->astOperand1();
|
const Token *lhs = gparent->astOperand1();
|
||||||
|
|
|
@ -3066,6 +3066,13 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("int& g(int* p, int& r) {\n" // #11625
|
||||||
|
" if (p)\n"
|
||||||
|
" return *p;\n"
|
||||||
|
" return r;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void constParameterCallback() {
|
void constParameterCallback() {
|
||||||
|
|
Loading…
Reference in New Issue