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

            Bug ID: 70085
           Summary: False positive -Wmisleading-indentation
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: joel at gcc dot gnu.org
  Target Milestone: ---

In code which indents cpp directives to match the code, the checker is
confused. The following example is sufficient to generate the warning.


=======================
#define ENABLE_FEATURE

int f(int x, int y)
{
  if (x > y)
    return x - y;

  #ifdef ENABLE_FEATURE
    if (x == y)
      return 0;
  #endif

  return -1;
}
=======================

sparc-rtems4.12-gcc (GCC) 6.0.0 20160228 (RTEMS 4.12, RSB
b537e5536459e207fc8e56a1df3774c1700606d5, Newlib 2.3.0.20160226)


indent.c: In function 'f':
indent.c:9:5: warning: statement is indented as if it were guarded by...
[-Wmisleading-indentation]
     if (x == y)
     ^~
indent.c:5:3: note: ...this 'if' clause, but it is not
   if (x > y)
   ^~

Reply via email to