Fix issue 8865: FP with dangling lifetime
This fixes: ```cpp void f(uint32_t event, unsigned long op, const xen_ulong_t *args) { struct __packed { uint32_t op; uint32_t args[6]; } d; uint32_t *a = d.args; } ```
This commit is contained in:
parent
2c803a1ead
commit
229c45e7f8
|
@ -643,7 +643,8 @@ void CheckAutoVariables::checkVarLifetimeScope(const Token * start, const Token
|
||||||
} else if (isDeadScope(val.tokvalue, tok->scope())) {
|
} else if (isDeadScope(val.tokvalue, tok->scope())) {
|
||||||
errorInvalidLifetime(tok, &val);
|
errorInvalidLifetime(tok, &val);
|
||||||
break;
|
break;
|
||||||
} else if (tok->variable() && !tok->variable()->isLocal() && !tok->variable()->isArgument() &&
|
} else if (tok->variable() && tok->variable()->declarationId() == tok->varId() &&
|
||||||
|
!tok->variable()->isLocal() && !tok->variable()->isArgument() &&
|
||||||
isInScope(val.tokvalue, tok->scope())) {
|
isInScope(val.tokvalue, tok->scope())) {
|
||||||
errorDanglngLifetime(tok, &val);
|
errorDanglngLifetime(tok, &val);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1510,6 +1510,14 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void f() {\n"
|
||||||
|
" struct b {\n"
|
||||||
|
" uint32_t f[6];\n"
|
||||||
|
" } d;\n"
|
||||||
|
" uint32_t *a = d.f;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
// Make sure we dont hang
|
// Make sure we dont hang
|
||||||
check("struct A;\n"
|
check("struct A;\n"
|
||||||
"void f() {\n"
|
"void f() {\n"
|
||||||
|
|
Loading…
Reference in New Issue