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

            Bug ID: 69126
           Summary: [6 regression] _Pragma does not apply if part of a
                    macro
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thiago at kde dot org
  Target Milestone: ---

$ cat /tmp/test.cpp
#pragma GCC diagnostic push
int f()
{
    _Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
    int x;
    return 0;
}
#pragma GCC diagnostic pop

#pragma GCC diagnostic push
#define MACRO \
    _Pragma("GCC diagnostic ignored \"-Wunused-variable\"") \
    int x;

int g()
{
    MACRO;
    return 0;
}
#pragma GCC diagnostic pop

With GCC 4.8.5 or 5.3.1:
$ gcc -O2 -Wall -c /tmp/test.cpp  
[nothing printed]

With GCC 6:
$ ~/gcc6/bin/gcc -O2 -Wall -c /tmp/test.cpp  
/tmp/test.cpp: In function ‘int g()’:
/tmp/test.cpp:13:9: warning: unused variable ‘x’ [-Wunused-variable]
     int x;
         ^

/tmp/test.cpp:17:5: note: in expansion of macro ‘MACRO’
     MACRO;
     ^~~~~

GCC 6 built from trunk last night (20160103).

Reply via email to