Skip to content

COR091 exit-or-cycle-in-unlabelled-loop ​

warning opt-in

An exit or cycle appears in a DO loop that has no construct name.

Why ​

In nested loops a bare exit/cycle acts on the innermost loop only, which is easy to misread. Naming the loop and the statement (exit cells) states which loop is meant.

Reported ​

fortran
do i = 1, n
  if (done(i)) exit
end do

Preferred ​

fortran
cells: do i = 1, n
  if (done(i)) exit cells
end do cells

Suppressing ​

For one occurrence, with the reason on the same line (or alone on the line before the statement):

fortran
! fobis: ignore[COR091] <why this occurrence is fine>

For the whole project, ignore = COR091 in the fobos [lint] section.

Equivalent ​

Fortitude rule C142 (see Lint Rules).