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();
|
const Token* branchTok = tok->astOperand2();
|
||||||
if (!branchTok->astOperand1()->valueType())
|
if (!branchTok->astOperand1()->valueType())
|
||||||
return false;
|
return false;
|
||||||
|
if (!branchTok->astOperand2()->valueType())
|
||||||
|
return false;
|
||||||
return !branchTok->astOperand1()->valueType()->isTypeEqual(branchTok->astOperand2()->valueType());
|
return !branchTok->astOperand1()->valueType()->isTypeEqual(branchTok->astOperand2()->valueType());
|
||||||
}
|
}
|
||||||
if (Token::simpleMatch(tok, "(") && tok->astOperand1() &&
|
if (Token::simpleMatch(tok, "(") && tok->astOperand1() &&
|
||||||
|
|
|
@ -3733,6 +3733,14 @@ private:
|
||||||
"}\n",
|
"}\n",
|
||||||
true);
|
true);
|
||||||
ASSERT_EQUALS("", errout.str());
|
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()
|
void danglingLifetimeBorrowedMembers()
|
||||||
|
|
Loading…
Reference in New Issue