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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |ppalka at gcc dot gnu.org
         Resolution|---                         |FIXED
   Target Milestone|---                         |6.0

--- Comment #8 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Good news, with GCC 6's new -Wmisleading-indentation flag we emit the
appropriate warning for the test case in comment #1:

62184.C: In function ‘int foo()’:
62184.C:5:3: warning: this ‘while’ clause does not guard...
[-Wmisleading-indentation]
   while (bar());
   ^~~~~
62184.C:6:5: note: ...this statement, but the latter is misleadingly indented
as if it is guarded by the ‘while’
     sleep();
     ^~~~~


As for the test case in comment #6:

    int main()
    {
        for (; 1<2; );
        if (1==1);
        while (1==1);
        return 0;
    }

We don't and arguably shouldn't warn, because none of the statements are
indented as if they're intended to be guarded by a previous one.  However, we
do warn (twice) for

    int main()
    {
        for (; 1<2; );
          if (1==1);
        while (1==1);
          return 0;
    }

So I think this PR can finally be closed.

Reply via email to