parent
3836367d95
commit
4d72e0f5b5
|
@ -1548,8 +1548,11 @@ void CheckOther::checkConstPointer()
|
|||
const Token* const gparent = parent->astParent();
|
||||
if (Token::Match(gparent, "%cop%") && !gparent->isUnaryOp("&") && !gparent->isUnaryOp("*"))
|
||||
continue;
|
||||
if (Token::simpleMatch(gparent, "return"))
|
||||
continue;
|
||||
if (Token::simpleMatch(gparent, "return")) {
|
||||
const Function* function = gparent->scope()->function;
|
||||
if (function && (!Function::returnsReference(function) || Function::returnsConst(function)))
|
||||
continue;
|
||||
}
|
||||
else if (Token::Match(gparent, "%assign%") && parent == gparent->astOperand2()) {
|
||||
bool takingRef = false, nonConstPtrAssignment = false;
|
||||
const Token *lhs = gparent->astOperand1();
|
||||
|
|
|
@ -3066,6 +3066,13 @@ private:
|
|||
" }\n"
|
||||
"}\n");
|
||||
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() {
|
||||
|
|
Loading…
Reference in New Issue