https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79227

--- Comment #1 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Some notes:

There are 7 cases in the reproducer, but it only warns for the 3rd case (lines
34-35).

In each of the 7 cases in the reproducer, NEXT_STMT_LOC and BODY_LOC are on the
same line:

  /* If NEXT_STMT_LOC and BODY_LOC are on the same line, consider
     the location of the guard.

Case 3 matches the following conditional, and thus warns:

      if (guard_exploc.line < body_exploc.line)
        /* The guard is on a line before a line that contains both
           the body and the next stmt.  */
        return true;

whereas the other cases match this conditional:

      else if (guard_exploc.line == body_exploc.line)
        {
          /* They're all on the same line.  */

and try this heuristic:

          /* Heuristic: only warn if the guard is the first thing
             on its line.  */
          if (guard_vis_column == guard_line_first_nws)
            return true;

...which doesn't match, hence we don't warn for them.

Reply via email to