Fix 11442: new "Reference to temporary returned." FPs (#4657)
This commit is contained in:
parent
2cd8bb94e4
commit
da32c5aecd
|
@ -407,6 +407,8 @@ bool isTemporary(bool cpp, const Token* tok, const Library* library, bool unknow
|
|||
const Token* branchTok = tok->astOperand2();
|
||||
if (!branchTok->astOperand1()->valueType())
|
||||
return false;
|
||||
if (!branchTok->astOperand2()->valueType())
|
||||
return false;
|
||||
return !branchTok->astOperand1()->valueType()->isTypeEqual(branchTok->astOperand2()->valueType());
|
||||
}
|
||||
if (Token::simpleMatch(tok, "(") && tok->astOperand1() &&
|
||||
|
|
|
@ -3733,6 +3733,14 @@ private:
|
|||
"}\n",
|
||||
true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #11442
|
||||
check("const std::string& f(const P< std::string >& value) {\n"
|
||||
" static const std::string empty;\n"
|
||||
" return value.get() == nullptr ? empty : *value;\n"
|
||||
"}\n",
|
||||
true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void danglingLifetimeBorrowedMembers()
|
||||
|
|
Loading…
Reference in New Issue