* Fix #11362 FP returnDanglingLifetime for pointer to struct member in static array * Undo
This commit is contained in:
parent
515369739c
commit
e046232535
|
@ -410,7 +410,7 @@ static bool isInScope(const Token * tok, const Scope * scope)
|
||||||
const Variable * var = tok->variable();
|
const Variable * var = tok->variable();
|
||||||
if (var && (var->isGlobal() || var->isStatic() || var->isExtern()))
|
if (var && (var->isGlobal() || var->isStatic() || var->isExtern()))
|
||||||
return false;
|
return false;
|
||||||
if (tok->scope() && tok->scope()->isNestedIn(scope))
|
if (tok->scope() && !tok->scope()->isClassOrStructOrUnion() && tok->scope()->isNestedIn(scope))
|
||||||
return true;
|
return true;
|
||||||
if (!var)
|
if (!var)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -3050,6 +3050,13 @@ private:
|
||||||
" return std::tie(xs[i]...);\n"
|
" return std::tie(xs[i]...);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #11362
|
||||||
|
check("int* f() {\n"
|
||||||
|
" static struct { int x; } a[] = { { 1 } };\n"
|
||||||
|
" return &a[0].x;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void danglingLifetimeFunction() {
|
void danglingLifetimeFunction() {
|
||||||
|
|
Loading…
Reference in New Issue