c++: -Wdeprecated-copy and #pragma diagnostic [PR94492]
authorJason Merrill <jason@redhat.com>
Tue, 27 Apr 2021 21:13:39 +0000 (17:13 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 1 Jun 2021 15:35:47 +0000 (11:35 -0400)
commit620cd7861e1266991c9c2a82e1e2d5f4d723ec88
tree107b4735c89087ccbfe98dedeff16a1841bc7ba2
parent18b88412069f51433e1b4f440d3c035bfc7b5cca
c++: -Wdeprecated-copy and #pragma diagnostic [PR94492]

-Wdeprecated-copy was depending only on the state of the warning at the
point where we call the function, making it hard to use #pragma diagnostic
to suppress the warning for a particular implicitly declared function.

But checking whether the warning is enabled at the location of the implicit
declaration turned out to be a bit complicated; option_enabled only tests
whether it was enabled at the start of compilation, the actual test only
existed in the middle of diagnostic_report_diagnostic.  So this patch
factors it out and adds a new warning_enabled function to diagnostic.h.

gcc/ChangeLog:

PR c++/94492
* diagnostic.h (warning_enabled_at): Declare.
* diagnostic.c (diagnostic_enabled): Factor out from...
(diagnostic_report_diagnostic): ...here.
(warning_enabled_at): New.

gcc/cp/ChangeLog:

PR c++/94492
* decl2.c (cp_warn_deprecated_use): Check warning_enabled_at.

gcc/testsuite/ChangeLog:

PR c++/94492
* g++.dg/cpp0x/depr-copy4.C: New test.
gcc/cp/decl2.c
gcc/diagnostic.c
gcc/diagnostic.h
gcc/testsuite/g++.dg/cpp0x/depr-copy4.C [new file with mode: 0644]