Fixed #4649 (false positive: Used file that is not opened; variables in struct)

This commit is contained in:
kchrist 2013-03-15 06:42:46 +01:00 committed by Daniel Marjamäki
parent c0a34649c4
commit 740e790bf1
2 changed files with 13 additions and 0 deletions

View File

@ -205,6 +205,9 @@ void CheckIO::checkFileUsage()
}
}
while (Token::Match(fileTok, "%var% ."))
fileTok = fileTok->tokAt(2);
if (!fileTok || !fileTok->varId())
continue;

View File

@ -338,6 +338,16 @@ private:
" }\n"
"}");
ASSERT_EQUALS("", errout.str());
// #4649
check("void foo() {\n"
" struct {FILE *f1; FILE *f2;} a;\n"
" a.f1 = fopen(name,mode);\n"
" a.f2 = fopen(name,mode);\n"
" fclose(a.f1);\n"
" fclose(a.f2);\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void fileIOwithoutPositioning() {