Fix issue 9770: FP returnDanglingLifetime for class method taking const char* and returning std::string
This commit is contained in:
parent
72fa5f2e27
commit
0cc1f69862
|
@ -3068,7 +3068,7 @@ static bool isLifetimeBorrowed(const ValueType *vt, const ValueType *vtParent)
|
||||||
return false;
|
return false;
|
||||||
if (!vt)
|
if (!vt)
|
||||||
return false;
|
return false;
|
||||||
if (vt->type != ValueType::UNKNOWN_TYPE && vtParent->type != ValueType::UNKNOWN_TYPE) {
|
if (vt->type != ValueType::UNKNOWN_TYPE && vtParent->type != ValueType::UNKNOWN_TYPE && vtParent->container == vt->container) {
|
||||||
if (vtParent->pointer > vt->pointer)
|
if (vtParent->pointer > vt->pointer)
|
||||||
return true;
|
return true;
|
||||||
if (vtParent->pointer < vt->pointer && vtParent->isIntegral())
|
if (vtParent->pointer < vt->pointer && vtParent->isIntegral())
|
||||||
|
|
|
@ -2328,6 +2328,16 @@ private:
|
||||||
" return value;\n"
|
" return value;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #9770
|
||||||
|
check("class C {\n"
|
||||||
|
" std::string f(const char*);\n"
|
||||||
|
"};\n"
|
||||||
|
"std::string C::f(const char*) {\n"
|
||||||
|
" const char data[] = \"x\";\n"
|
||||||
|
" return data;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void danglingLifetimeFunction() {
|
void danglingLifetimeFunction() {
|
||||||
|
|
Loading…
Reference in New Issue