This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/72797] New: bogus -Wmisleading-indentation with -ftrack-macro-expansion=0 on a multi-statement macro


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

            Bug ID: 72797
           Summary: bogus -Wmisleading-indentation with
                    -ftrack-macro-expansion=0 on a multi-statement macro
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

When invoked with the -ftrack-macro-expansion=0 and -Wmisleading-indentation,
GCC warns on the following program derived from a GCC test suite.  Since the
code is clearly indented and there is no mention of the -ftrack-macro-expansion
option having this effect, the warning is unexpected.

In addition, the documentation for -ftrack-macro-expansion=level says that 

  Value '0' of level de-activates this option just as if no
-ftrack-macro-expansion was present on the command line. 

Contrary to the statement above, GCC output changes and the warning disappears
when the -ftrack-macro-expansion option is removed.

The warning also disappears with -ftrack-macro-expansion=1 and greater, or when
the body of the if statement is encloses in braces.

$ cat xyz.c && /build/gcc-trunk-svn/gcc/xgcc -B /build/gcc-trunk-svn/gcc -O -S
-Wall -Wextra -Wpedantic -ftrack-macro-expansion=0 xyz.c
int i;

void f (void)
{
#define T()                                     \
  do {                                          \
    if (i)                                      \
      i = 0;                                    \
    i++;                                        \
  } while (0)

  T ();
}
xyz.c: In function ‘f’:
xyz.c:12:3: warning: this ‘if’ clause does not guard...
[-Wmisleading-indentation]
   T ();
   ^
xyz.c:12:3: note: ...this statement, but the latter is misleadingly indented as
if it is guarded by the ‘if’

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]