Formatting
This commit is contained in:
parent
bb37b07def
commit
264c0cae8b
|
@ -530,12 +530,14 @@ void CheckAutoVariables::checkVarLifetimeScope(const Token * start, const Token
|
|||
} else if (tokvalue->variable() && isDeadScope(tokvalue->variable()->nameToken(), tok->scope())) {
|
||||
errorInvalidLifetime(tok, &val);
|
||||
break;
|
||||
} else if (!tokvalue->variable() && isDeadTemporary(mTokenizer->isCPP(), tokvalue, tok, &mSettings->library)) {
|
||||
} else if (!tokvalue->variable() &&
|
||||
isDeadTemporary(mTokenizer->isCPP(), tokvalue, tok, &mSettings->library)) {
|
||||
errorDanglingTemporaryLifetime(tok, &val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tokvalue->variable() && (isInScope(tokvalue->variable()->nameToken(), tok->scope()) || (val.isSubFunctionLifetimeValue() && tokvalue->variable()->isLocal()))) {
|
||||
if (tokvalue->variable() && (isInScope(tokvalue->variable()->nameToken(), tok->scope()) ||
|
||||
(val.isSubFunctionLifetimeValue() && tokvalue->variable()->isLocal()))) {
|
||||
const Variable * var = nullptr;
|
||||
const Token * tok2 = tok;
|
||||
if (Token::simpleMatch(tok->astParent(), "=")) {
|
||||
|
|
|
@ -217,7 +217,8 @@ namespace ValueFlow {
|
|||
return valueType == ValueType::LIFETIME && lifetimeScope == LifetimeScope::Argument;
|
||||
}
|
||||
|
||||
bool isSubFunctionLifetimeValue() const {
|
||||
bool isSubFunctionLifetimeValue() const
|
||||
{
|
||||
return valueType == ValueType::LIFETIME && lifetimeScope == LifetimeScope::SubFunction;
|
||||
}
|
||||
|
||||
|
|
|
@ -2167,7 +2167,9 @@ private:
|
|||
" add(&i);\n"
|
||||
" }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:8] -> [test.cpp:4] -> [test.cpp:7] -> [test.cpp:4]: (error) Non-local variable 'v' will use object that points to local variable 'i'.\n", errout.str());
|
||||
ASSERT_EQUALS(
|
||||
"[test.cpp:8] -> [test.cpp:8] -> [test.cpp:4] -> [test.cpp:7] -> [test.cpp:4]: (error) Non-local variable 'v' will use object that points to local variable 'i'.\n",
|
||||
errout.str());
|
||||
}
|
||||
|
||||
void danglingLifetime() {
|
||||
|
|
Loading…
Reference in New Issue