parent
163fb79de1
commit
ac41b45a5f
|
@ -614,7 +614,7 @@ void CheckAutoVariables::checkVarLifetimeScope(const Token * start, const Token
|
|||
const Token* nextTok = nextAfterAstRightmostLeaf(tok->astTop());
|
||||
if (!nextTok)
|
||||
nextTok = tok->next();
|
||||
if (var && !var->isLocal() && !var->isArgument() &&
|
||||
if (var && !var->isLocal() && !var->isArgument() && !(val.tokvalue && val.tokvalue->variable() && val.tokvalue->variable()->isStatic()) &&
|
||||
!isVariableChanged(nextTok,
|
||||
tok->scope()->bodyEnd,
|
||||
var->declarationId(),
|
||||
|
|
|
@ -3273,6 +3273,19 @@ private:
|
|||
" return { {}, {} };\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #11729
|
||||
check("struct T {\n"
|
||||
" void add(int* i) {\n"
|
||||
" v.push_back(i);\n"
|
||||
" }\n"
|
||||
" void f() {\n"
|
||||
" static int val = 1;\n"
|
||||
" add(&val);\n"
|
||||
" }\n"
|
||||
" std::vector<int*> v;\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void danglingLifetimeFunction() {
|
||||
|
|
Loading…
Reference in New Issue