aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlex Coplan <alex.coplan@arm.com>2023-03-22 15:20:49 +0000
committerAlex Coplan <alex.coplan@arm.com>2023-03-22 15:20:49 +0000
commitd3a6f174543816600b1f472997d492088e4e396a (patch)
treeac8c60dada910999b3acb7bd444c69b9f8ac54ff /gcc
parent0c652ebbf79bd168766097f3ac4c1b3b79d68a43 (diff)
downloadgcc-d3a6f174543816600b1f472997d492088e4e396a.zip
gcc-d3a6f174543816600b1f472997d492088e4e396a.tar.gz
gcc-d3a6f174543816600b1f472997d492088e4e396a.tar.bz2
c++: Avoid duplicate diagnostic calling unavailable function [PR109177]
As the PR shows, we currently emit duplicate diagnostics for calls to functions marked with __attribute__((unavailable)). This patch fixes that. 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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/call.cc10
-rw-r--r--gcc/testsuite/g++.dg/ext/pr109177.C6
2 files changed, 12 insertions, 4 deletions
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index c52a09b..d5e8ccc 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 0000000..cc322f6
--- /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 }
+}