[Bug preprocessor/89038] New: #pragma GCC diagnostic ignored "-Wunknown-pragmas" does not work

ulidtko at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Jan 24 14:46:00 GMT 2019


            Bug ID: 89038
           Summary: #pragma GCC diagnostic ignored "-Wunknown-pragmas"
                    does not work
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ulidtko at gmail dot com
  Target Milestone: ---

Consider this test.cxx file:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wunknown-pragmas"

// this gets silenced correctly (by line 2)
#pragma GCC diagnostic ignored "-Wfoobar-unknown-gcc-pragma"

// this still emits "-Wunknown-pragmas", despite line 3
#pragma clang diagnostic ignored "-Wfoobar-unknown-clang-pragma"

int main() {}

#pragma GCC diagnostic pop

g++ -Wall -Werror test.cxx

test.cxx:9:0: error: ignoring #pragma clang diagnostic
 #pragma clang diagnostic ignored "-Wfoobar-unknown-clang-pragma"

This happens despite the fact that "-Wunknown-pragmas" is explicitly silenced
in line 3.

Adding -Wno-unknown-pragmas to the command line works as expected; however, I
expect the in-source #pragma to work as well. But it doesn't.

g++ (GCC) 7.2.1 20180104 (Red Hat 7.2.1-5)

Bug #53431 seems closely related.

More information about the Gcc-bugs mailing list