* [PATCH] c++: Avoid duplicate diagnostic calling unavailable function [PR109177]
@ 2023-03-22 11:32 Alex Coplan
2023-03-22 15:10 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Alex Coplan @ 2023-03-22 11:32 UTC (permalink / raw)
To: gcc-patches; +Cc: Jason Merrill, Nathan Sidwell
[-- Attachment #1: Type: text/plain, Size: 652 bytes --]
Hi,
As the PR shows, we currently emit duplicate diagnostics for calls to
functions marked with __attribute__((unavailable)). This patch fixes
that.
I'm not sure whether it's considered acceptable to add the include of
decl.h to call.cc (in order to get at deprecated_state). It would be
useful to get some feedback on that.
Bootstrapped/regtested on aarch64-linux-gnu, OK for trunk?
Thanks,
Alex
gcc/cp/ChangeLog:
PR c++/109177
* call.cc (build_over_call): Use make_temp_override to suppress
both unavailable and deprecated warnings when calling
build_addr_func.
gcc/testsuite/ChangeLog:
PR c++/109177
* g++.dg/ext/pr109177.C: New test.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1498 bytes --]
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index c52a09b9be2..d5e8ccc07d3 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. If not see
#include "internal-fn.h"
#include "stringpool.h"
#include "attribs.h"
+#include "decl.h"
#include "gcc-rich-location.h"
/* The various kinds of conversion. */
@@ -10413,10 +10414,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 redundantly issuing another one
- from build_addr_func. */
- warning_sentinel w (warn_deprecated_decl);
+ /* If FN is marked deprecated or unavailable, then we've already
+ issued a diagnostic from mark_used above, so avoid redundantly
+ issuing another one from build_addr_func. */
+ auto w = make_temp_override (deprecated_state,
+ UNAVAILABLE_DEPRECATED_SUPPRESS);
fn = build_addr_func (fn, complain);
if (fn == error_mark_node)
diff --git a/gcc/testsuite/g++.dg/ext/pr109177.C b/gcc/testsuite/g++.dg/ext/pr109177.C
new file mode 100644
index 00000000000..cc322f650af
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/pr109177.C
@@ -0,0 +1,6 @@
+// { dg-do compile }
+void foo() __attribute__((unavailable));
+void bar () {
+ foo (); // { dg-bogus "is unavailable.*is unavailable" }
+ // { dg-error "is unavailable" "" { target *-*-* } .-1 }
+}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] c++: Avoid duplicate diagnostic calling unavailable function [PR109177]
2023-03-22 11:32 [PATCH] c++: Avoid duplicate diagnostic calling unavailable function [PR109177] Alex Coplan
@ 2023-03-22 15:10 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2023-03-22 15:10 UTC (permalink / raw)
To: Alex Coplan, gcc-patches; +Cc: Nathan Sidwell
On 3/22/23 07:32, Alex Coplan wrote:
> Hi,
>
> As the PR shows, we currently emit duplicate diagnostics for calls to
> functions marked with __attribute__((unavailable)). This patch fixes
> that.
>
> I'm not sure whether it's considered acceptable to add the include of
> decl.h to call.cc (in order to get at deprecated_state). It would be
> useful to get some feedback on that.
That's fine.
> Bootstrapped/regtested on aarch64-linux-gnu, OK for trunk?
OK.
> gcc/cp/ChangeLog:
>
> PR c++/109177
> * call.cc (build_over_call): Use make_temp_override to suppress
> both unavailable and deprecated warnings when calling
> build_addr_func.
>
> gcc/testsuite/ChangeLog:
>
> PR c++/109177
> * g++.dg/ext/pr109177.C: New test.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-22 15:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-22 11:32 [PATCH] c++: Avoid duplicate diagnostic calling unavailable function [PR109177] Alex Coplan
2023-03-22 15:10 ` 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).