Skip to content

Commit d7a37ad

Browse files
fixup! fixup! fixup! fixup! fixup! Fix #958: warn when feof() is used as a while loop condition
1 parent 853ba8a commit d7a37ad

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lib/checkio.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,8 @@ void CheckIO::checkWrongfeofUsage()
549549
bodyEnd = tok->previous();
550550
bodyStart = bodyEnd->link();
551551
} else {
552+
if (!Token::simpleMatch(endCond, ") {"))
553+
continue;
552554
bodyEnd = endCond->linkAt(1);
553555
bodyStart = endCond->next();
554556
}
@@ -614,8 +616,8 @@ void CheckIO::checkWrongfeofUsage()
614616
}
615617

616618
// Search for any destination use between this call's ';' and endBody
617-
const Token *SemiColonTok = lastLoopFileReadCallTok->linkAt(1)->next();
618-
for (const Token *t = SemiColonTok; t && t != bodyEnd; t = t->next()) {
619+
const Token *semiColonTok = lastLoopFileReadCallTok->linkAt(1)->next();
620+
for (const Token *t = semiColonTok; t && t != bodyEnd; t = t->next()) {
619621
if (std::find(destVarIds.begin(), destVarIds.end(), t->varId()) != destVarIds.end()) {
620622
wrongfeofUsage(getCondTok(tok));
621623
break;

0 commit comments

Comments
 (0)