Fix autovarInvalidDeallocation regression (#5203)
This commit is contained in:
parent
1b4ec0def4
commit
818ebb8d7e
|
@ -303,7 +303,7 @@ void CheckAutoVariables::autoVariables()
|
||||||
if (v.isImpossible())
|
if (v.isImpossible())
|
||||||
continue;
|
continue;
|
||||||
if ((v.isTokValue() && (isArrayVar(v.tokvalue) || ((v.tokvalue->tokType() == Token::eString)))) ||
|
if ((v.isTokValue() && (isArrayVar(v.tokvalue) || ((v.tokvalue->tokType() == Token::eString)))) ||
|
||||||
(v.isLocalLifetimeValue() && v.lifetimeKind == ValueFlow::Value::LifetimeKind::Address)) {
|
(v.isLocalLifetimeValue() && v.lifetimeKind == ValueFlow::Value::LifetimeKind::Address && !Token::simpleMatch(v.tokvalue, "("))) {
|
||||||
errorInvalidDeallocation(tok, &v);
|
errorInvalidDeallocation(tok, &v);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -847,6 +847,12 @@ private:
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void f() {\n"
|
||||||
|
" S* p = &g();\n"
|
||||||
|
" delete p;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testinvaliddealloc_input() {
|
void testinvaliddealloc_input() {
|
||||||
|
|
Loading…
Reference in New Issue