Fix FP with non-local variable referencing a non-local variable (#1864)
This commit is contained in:
parent
6ae7be0f53
commit
8a1c0dd017
|
@ -630,7 +630,7 @@ void CheckAutoVariables::checkVarLifetimeScope(const Token * start, const Token
|
|||
break;
|
||||
} else if (tok->variable() && tok->variable()->declarationId() == tok->varId() &&
|
||||
!tok->variable()->isLocal() && !tok->variable()->isArgument() &&
|
||||
isInScope(val.tokvalue, tok->scope())) {
|
||||
isInScope(val.tokvalue->variable()->nameToken(), tok->scope())) {
|
||||
errorDanglngLifetime(tok, &val);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1721,6 +1721,15 @@ private:
|
|||
" std::map< S, B > m2;\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct A {\n"
|
||||
" std::vector<int*> v;\n"
|
||||
" int x;\n"
|
||||
" void f() {\n"
|
||||
" v.push_back(&x);\n"
|
||||
" }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void danglingLifetime() {
|
||||
|
|
Loading…
Reference in New Issue