[Bug c/69122] New: -Wmisleading-indentation false positive with empty macros

thiago at kde dot org gcc-bugzilla@gcc.gnu.org
Sun Jan 3 13:02:00 GMT 2016


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

            Bug ID: 69122
           Summary: -Wmisleading-indentation false positive with empty
                    macros
           Product: gcc
           Version: 5.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thiago at kde dot org
  Target Milestone: ---

When a statement is preceded by an empty macro, the warning triggers
incorrectly:

$ cat /tmp/test.c 
#define emit
void g();
void f(int x)
{
    if (x)
         g();
    emit g();
}

$ ~/gcc6/bin/gcc -c -O3 -Wall /tmp/test.c
/tmp/test.c: In function ‘f’:
/tmp/test.c:7:10: warning: statement is indented as if it were guarded by...
[-Wmisleading-indentation]
     emit g();
          ^

/tmp/test.c:5:5: note: ...this ‘if’ clause, but it is not
     if (x)
     ^~

$ ~/gcc6/bin/gcc -E /tmp/test.c | ~/gcc6/bin/gcc -c -O3 -Wall -xc -
[no error]

This also happens in C++ and happens often in Qt code due to the empty "emit"
macro.


More information about the Gcc-bugs mailing list