Fixed #4649 (false positive: Used file that is not opened; variables in struct)
This commit is contained in:
parent
c0a34649c4
commit
740e790bf1
|
@ -205,6 +205,9 @@ void CheckIO::checkFileUsage()
|
|||
}
|
||||
}
|
||||
|
||||
while (Token::Match(fileTok, "%var% ."))
|
||||
fileTok = fileTok->tokAt(2);
|
||||
|
||||
if (!fileTok || !fileTok->varId())
|
||||
continue;
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue