https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80076
Bug ID: 80076 Summary: -Wmisleading-indentation doesn't trigger when macro is misindented Product: gcc Version: 7.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: andres at anarazel dot de CC: dmalcolm at gcc dot gnu.org Target Milestone: --- Created attachment 40989 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40989&action=edit reproducer Hi, -Wmisleading-indentation doesn't trigger when the misindented part of the code consists of a macro. The attached example is silent when a macro is used, and warns when a function is used. #ifdef TRIGGER static void elog(char *msg) { } #else #define elog(Y) printf(Y) #endif void foo (void); void test (int flag) { if (flag) foo (); elog("could not identify CTID variable"); } andres@alap4:~$ gcc -DTRIGGER -Wmisleading-indentation -c /tmp/repro.c /tmp/repro.c: In function 'test': /tmp/repro.c:13:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation] if (flag) ^~ /tmp/repro.c:15:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if' elog("could not identify CTID variable"); ^~~~ andres@alap4:~$ gcc -Wmisleading-indentation -c /tmp/repro.c andres@alap4:~$ gcc --version gcc (Debian 20170226-1) 7.0.1 20170226 (experimental) [trunk revision 245744] Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Not sure if this is a known "issue", or not. If it's hard to make that work reliably for macros... Andres