This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/72797] New: bogus -Wmisleading-indentation with -ftrack-macro-expansion=0 on a multi-statement macro
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 03 Aug 2016 17:57:57 +0000
- Subject: [Bug c/72797] New: bogus -Wmisleading-indentation with -ftrack-macro-expansion=0 on a multi-statement macro
- Auto-submitted: auto-generated
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’