* [PATCH] c++: Redundant -Wdeprecated-declarations warning in build_over_call (PR 67960)
@ 2020-03-12 19:28 Patrick Palka
2020-03-13 5:56 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Patrick Palka @ 2020-03-12 19:28 UTC (permalink / raw)
To: gcc-patches
In build_over_call, we are emitting a redundant -Wdeprecated-declarations
warning about the deprecated callee function, first from mark_used and again
from build_addr_func <- decay_conversion <- cp_build_addr_expr <- mark_used.
It seems this warning coming from build_addr_func will always be redundant, so
we can safely use a warning_sentinel to disable the warning before calling
build_addr_func. (And any deprecation warning that could come from
build_addr_func would be for FN, and so we wouldn't be suppressing too much.)
Tested on x86_64-pc-linux-gnu. Does this look OK to commit?
gcc/cp/ChangeLog:
PR c++/67960
* call.c (build_over_call): Use a warning_sentinel to disable
warn_deprecated_decl before calling build_addr_func.
gcc/testsuite/ChangeLog:
PR c++/67960
g++.dg/diagnostic/pr67960.C: New test.
g++.dg/diagnostic/pr67960-2.C: New test.
---
gcc/cp/call.c | 5 +++++
gcc/testsuite/g++.dg/diagnostic/pr67960-2.C | 13 +++++++++++++
gcc/testsuite/g++.dg/diagnostic/pr67960.C | 13 +++++++++++++
3 files changed, 31 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/diagnostic/pr67960-2.C
create mode 100644 gcc/testsuite/g++.dg/diagnostic/pr67960.C
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 5767a8b8c4e..2f6cfd85175 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -9062,6 +9062,11 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
}
else
{
+ /* If FN is marked deprecated, then we've already issued a deprecated-use
+ warning from mark_used above, so avoid reduntantly issuing another one
+ from build_addr_func. */
+ warning_sentinel w (warn_deprecated_decl);
+
fn = build_addr_func (fn, complain);
if (fn == error_mark_node)
return error_mark_node;
diff --git a/gcc/testsuite/g++.dg/diagnostic/pr67960-2.C b/gcc/testsuite/g++.dg/diagnostic/pr67960-2.C
new file mode 100644
index 00000000000..d2ba509534f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/pr67960-2.C
@@ -0,0 +1,13 @@
+// PR c++/67960
+// { dg-do compile }
+// { dg-additional-options "-Werror -fmax-errors=1" }
+__attribute__((deprecated)) void doNothing(){}
+
+int
+main()
+{
+ doNothing(); // { dg-error "is deprecated" }
+}
+
+// { dg-message "all warnings being treated as errors" "" { target *-*-* } 0 }
+// { dg-bogus "compilation terminated" "" { target *-*-* } 0 }
diff --git a/gcc/testsuite/g++.dg/diagnostic/pr67960.C b/gcc/testsuite/g++.dg/diagnostic/pr67960.C
new file mode 100644
index 00000000000..d7b1a2d0811
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/pr67960.C
@@ -0,0 +1,13 @@
+// PR c++/67960
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-Werror -fmax-errors=1" }
+[[deprecated]] void doNothing(){}
+
+int
+main()
+{
+ doNothing(); // { dg-error "is deprecated" }
+}
+
+// { dg-message "all warnings being treated as errors" "" { target *-*-* } 0 }
+// { dg-bogus "compilation terminated" "" { target *-*-* } 0 }
--
2.26.0.rc1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] c++: Redundant -Wdeprecated-declarations warning in build_over_call (PR 67960)
2020-03-12 19:28 [PATCH] c++: Redundant -Wdeprecated-declarations warning in build_over_call (PR 67960) Patrick Palka
@ 2020-03-13 5:56 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2020-03-13 5:56 UTC (permalink / raw)
To: Patrick Palka, gcc-patches
On 3/12/20 3:28 PM, Patrick Palka wrote:
> In build_over_call, we are emitting a redundant -Wdeprecated-declarations
> warning about the deprecated callee function, first from mark_used and again
> from build_addr_func <- decay_conversion <- cp_build_addr_expr <- mark_used.
>
> It seems this warning coming from build_addr_func will always be redundant, so
> we can safely use a warning_sentinel to disable the warning before calling
> build_addr_func. (And any deprecation warning that could come from
> build_addr_func would be for FN, and so we wouldn't be suppressing too much.)
>
> Tested on x86_64-pc-linux-gnu. Does this look OK to commit?
>
> gcc/cp/ChangeLog:
>
> PR c++/67960
> * call.c (build_over_call): Use a warning_sentinel to disable
> warn_deprecated_decl before calling build_addr_func.
OK.
> gcc/testsuite/ChangeLog:
>
> PR c++/67960
> g++.dg/diagnostic/pr67960.C: New test.
> g++.dg/diagnostic/pr67960-2.C: New test.
> ---
> gcc/cp/call.c | 5 +++++
> gcc/testsuite/g++.dg/diagnostic/pr67960-2.C | 13 +++++++++++++
> gcc/testsuite/g++.dg/diagnostic/pr67960.C | 13 +++++++++++++
> 3 files changed, 31 insertions(+)
> create mode 100644 gcc/testsuite/g++.dg/diagnostic/pr67960-2.C
> create mode 100644 gcc/testsuite/g++.dg/diagnostic/pr67960.C
>
> diff --git a/gcc/cp/call.c b/gcc/cp/call.c
> index 5767a8b8c4e..2f6cfd85175 100644
> --- a/gcc/cp/call.c
> +++ b/gcc/cp/call.c
> @@ -9062,6 +9062,11 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
> }
> else
> {
> + /* If FN is marked deprecated, then we've already issued a deprecated-use
> + warning from mark_used above, so avoid reduntantly issuing another one
> + from build_addr_func. */
> + warning_sentinel w (warn_deprecated_decl);
> +
> fn = build_addr_func (fn, complain);
> if (fn == error_mark_node)
> return error_mark_node;
> diff --git a/gcc/testsuite/g++.dg/diagnostic/pr67960-2.C b/gcc/testsuite/g++.dg/diagnostic/pr67960-2.C
> new file mode 100644
> index 00000000000..d2ba509534f
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/diagnostic/pr67960-2.C
> @@ -0,0 +1,13 @@
> +// PR c++/67960
> +// { dg-do compile }
> +// { dg-additional-options "-Werror -fmax-errors=1" }
> +__attribute__((deprecated)) void doNothing(){}
> +
> +int
> +main()
> +{
> + doNothing(); // { dg-error "is deprecated" }
> +}
> +
> +// { dg-message "all warnings being treated as errors" "" { target *-*-* } 0 }
> +// { dg-bogus "compilation terminated" "" { target *-*-* } 0 }
> diff --git a/gcc/testsuite/g++.dg/diagnostic/pr67960.C b/gcc/testsuite/g++.dg/diagnostic/pr67960.C
> new file mode 100644
> index 00000000000..d7b1a2d0811
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/diagnostic/pr67960.C
> @@ -0,0 +1,13 @@
> +// PR c++/67960
> +// { dg-do compile { target c++14 } }
> +// { dg-additional-options "-Werror -fmax-errors=1" }
> +[[deprecated]] void doNothing(){}
> +
> +int
> +main()
> +{
> + doNothing(); // { dg-error "is deprecated" }
> +}
> +
> +// { dg-message "all warnings being treated as errors" "" { target *-*-* } 0 }
> +// { dg-bogus "compilation terminated" "" { target *-*-* } 0 }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-03-13 5:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-12 19:28 [PATCH] c++: Redundant -Wdeprecated-declarations warning in build_over_call (PR 67960) Patrick Palka
2020-03-13 5:56 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).