Ticket #5315: Memory leak analysis confused by ((variable).attribute) notation.

This commit is contained in:
Simon Martin 2014-05-08 20:51:18 +02:00
parent 25f40b8b97
commit 512e22d1ba
2 changed files with 12 additions and 1 deletions

View File

@ -7022,7 +7022,7 @@ bool Tokenizer::simplifyRedundantParentheses()
ret = true;
}
if (Token::Match(tok->previous(), "[,;{}] ( %var% ) .")) {
if (Token::Match(tok->previous(), "[(,;{}] ( %var% ) .")) {
// Remove the parentheses
tok->deleteThis();
tok->deleteNext();

View File

@ -5620,6 +5620,7 @@ private:
TEST_CASE(trac5030);
TEST_CASE(varid); // #5201: Analysis confused by (variable).attribute notation
TEST_CASE(varid_2); // #5315: Analysis confused by ((variable).attribute) notation
}
void err() {
@ -6158,6 +6159,16 @@ private:
"}", /*fname=*/0, /*isCPP=*/false);
TODO_ASSERT_EQUALS("[test.c:9]: (error) Memory leak: s.state_check_buff\n", "", errout.str());
}
void varid_2() { // #5315
check("typedef struct foo { char *realm; } foo;\n"
"void build_principal() {\n"
" foo f;\n"
" ((f)->realm) = strdup(realm);\n"
" if(f->realm == NULL) {}\n"
"}", /*fname=*/0, /*isCPP=*/false);
ASSERT_EQUALS("[test.c:6]: (error) Memory leak: f.realm\n", errout.str());
}
};