Fixed false positive useClosedFile when noreturn function is called (#7359)
This commit is contained in:
parent
0e8777ec99
commit
6d0c2f7253
|
@ -148,7 +148,7 @@ void CheckIO::checkFileUsage()
|
|||
i->second.lastOperation = Filepointer::UNKNOWN_OP;
|
||||
}
|
||||
}
|
||||
} else if (tok->str() == "return" || tok->str() == "continue" || tok->str() == "break") { // Reset upon return, continue or break
|
||||
} else if (tok->str() == "return" || tok->str() == "continue" || tok->str() == "break" || _settings->library.isnoreturn(tok)) { // Reset upon return, continue or break
|
||||
for (std::map<unsigned int, Filepointer>::iterator i = filepointers.begin(); i != filepointers.end(); ++i) {
|
||||
i->second.mode_indent = 0;
|
||||
i->second.mode = UNKNOWN_OM;
|
||||
|
|
|
@ -480,6 +480,18 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void chdcd_parse_nero(FILE *infile) {\n"
|
||||
" switch (mode) {\n"
|
||||
" case 0x0300:\n"
|
||||
" fclose(infile);\n"
|
||||
" exit(0);\n"
|
||||
" case 0x0500:\n"
|
||||
" fclose(infile);\n"
|
||||
" return;\n"
|
||||
" }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #4649
|
||||
check("void foo() {\n"
|
||||
" struct {FILE *f1; FILE *f2;} a;\n"
|
||||
|
|
Loading…
Reference in New Issue