Fixed false positive #5732: autovarInvalidDeallocation on pointer to array
This commit is contained in:
parent
bde6698bcd
commit
ea23a0467b
|
@ -78,7 +78,7 @@ bool CheckAutoVariables::isAutoVarArray(const Token *tok)
|
||||||
{
|
{
|
||||||
const Variable *var = tok->variable();
|
const Variable *var = tok->variable();
|
||||||
|
|
||||||
return (var && var->isLocal() && !var->isStatic() && var->isArray());
|
return (var && var->isLocal() && !var->isStatic() && var->isArray() && !var->isPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verification that we really take the address of a local variable
|
// Verification that we really take the address of a local variable
|
||||||
|
|
|
@ -501,6 +501,18 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (error) Deallocation of an auto-variable results in undefined behaviour.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (error) Deallocation of an auto-variable results in undefined behaviour.\n", errout.str());
|
||||||
|
|
||||||
|
// #5732
|
||||||
|
check("int main() {\n"
|
||||||
|
" long (*pKoeff)[256] = new long[9][256];\n"
|
||||||
|
" delete[] pKoeff;\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("int main() {\n"
|
||||||
|
" long *pKoeff[256];\n"
|
||||||
|
" delete[] pKoeff;\n"
|
||||||
|
"}");
|
||||||
|
TODO_ASSERT_EQUALS("[test.cpp:3]: (error) Deallocation of an auto-variable results in undefined behaviour.\n", "", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testassign1() { // Ticket #1819
|
void testassign1() { // Ticket #1819
|
||||||
|
|
Loading…
Reference in New Issue