Merge pull request #299 from simartin/ticket_5315

Ticket #5315: Memory leak analysis confused by ((var).attr) notation
This commit is contained in:
Daniel Marjamäki 2014-05-09 06:07:00 +02:00
commit 69fbf50081
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());
}
};