[Bug c/66298] -Wmisleading-indentation should also detect missing indentation

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Nov 7 15:52:00 GMT 2018


Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I believe there is no general consistency in the indentation of pragmas, some
projects never indent them, others put them at the same level as the previous
stmt, others at the same level as the next stmt.
To catch the
if (1)
  #pragma GCC diagnostics ...
we just should have a separate warning that warns if the body of an
if/else/while/for is a pragma handled as a statement.
Note, for OpenMP, this is covered by the standard and GCC already errors on
OpenMP standalone directives in such contexts, so you get an error for
if (1)
  #pragma omp flush
where flush is standalone directive, but not for
if (1)
  #pragma omp single
where single is not standalone directive and has associated non-pragma code.

More information about the Gcc-bugs mailing list