c-family: Avoid unnecessary work when -Wpragmas is being ignored
authorPatrick Palka <ppalka@redhat.com>
Mon, 9 Nov 2020 16:14:00 +0000 (11:14 -0500)
committerPatrick Palka <ppalka@redhat.com>
Mon, 9 Nov 2020 16:14:00 +0000 (11:14 -0500)
commit6624075e7e996d61143bf5fc106fa2cb61c614f6
tree2d4a7373402260ff0fe9b972f2d49339a09fb5e5
parent4394b1ce7731b04446555e034163b14b4f4a7f8d
c-family: Avoid unnecessary work when -Wpragmas is being ignored

This speeds up handle_pragma_diagnostic by avoiding computing a spelling
suggestion for an unrecognized option inside a #pragma directive when
-Wpragmas warnings are being suppressed.

In the range-v3 library, which contains many instances of

  #pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wpragmas"
  #pragma GCC diagnostic ignored "-Wfoo"
  ...
  #pragma GCC diagnostic pop

(where -Wfoo stands for a warning option we don't recognize), this
reduces compile time by 33% for some of its tests.

gcc/c-family/ChangeLog:

* c-pragma.c (handle_pragma_diagnostic): Split the
unknown-option -Wpragmas diagnostic into a warning and a
subsequent note containing a spelling suggestion.  Avoid
computing the suggestion if -Wpragmas warnings are being
suppressed.

gcc/testsuite/ChangeLog:

* gcc.dg/pragma-diag-6.c: Adjust expected diagnostics
accordingly.
gcc/c-family/c-pragma.c
gcc/testsuite/gcc.dg/pragma-diag-6.c