diff options
author | Jakub Jelinek <jakub@redhat.com> | 2024-09-13 16:13:01 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2024-09-13 16:13:01 +0200 |
commit | b7b67732e20217196f2a13a10fc3df4605b2b2ab (patch) | |
tree | 6e02940e181f9e0126b270afb8362a383c406983 | |
parent | 4963eb76918295a08a7c216bea986ab8e65c1cf8 (diff) | |
download | gcc-b7b67732e20217196f2a13a10fc3df4605b2b2ab.zip gcc-b7b67732e20217196f2a13a10fc3df4605b2b2ab.tar.gz gcc-b7b67732e20217196f2a13a10fc3df4605b2b2ab.tar.bz2 |
c++: Don't emit deprecated/unavailable attribute diagnostics when creating cdtor thunks [PR116678]
Another spot where we mark_used a function (in this case ctor or dtor)
even when it is just artificially used inside of thunks (emitted on mingw
with -Os for the testcase).
2024-09-13 Jakub Jelinek <jakub@redhat.com>
PR c++/116678
* optimize.cc: Include decl.h.
(maybe_thunk_body): Temporarily change deprecated_state to
UNAVAILABLE_DEPRECATED_SUPPRESS.
* g++.dg/warn/deprecated-20.C: New test.
-rw-r--r-- | gcc/cp/optimize.cc | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/deprecated-20.C | 16 |
2 files changed, 22 insertions, 0 deletions
diff --git a/gcc/cp/optimize.cc b/gcc/cp/optimize.cc index b8791d8..8429d85 100644 --- a/gcc/cp/optimize.cc +++ b/gcc/cp/optimize.cc @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "target.h" #include "cp-tree.h" +#include "decl.h" #include "stringpool.h" #include "cgraph.h" #include "debug.h" @@ -287,6 +288,11 @@ maybe_thunk_body (tree fn, bool force) if (ctor_omit_inherited_parms (fns[0])) return 0; + /* Don't diagnose deprecated or unavailable cdtors just because they + have thunks emitted for them. */ + auto du = make_temp_override (deprecated_state, + UNAVAILABLE_DEPRECATED_SUPPRESS); + DECL_ABSTRACT_P (fn) = false; if (!DECL_WEAK (fn)) { diff --git a/gcc/testsuite/g++.dg/warn/deprecated-20.C b/gcc/testsuite/g++.dg/warn/deprecated-20.C new file mode 100644 index 0000000..1911aef --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/deprecated-20.C @@ -0,0 +1,16 @@ +// PR c++/116678 +// { dg-do compile } +// { dg-options "-Os -pedantic" } + +struct S +{ + [[deprecated]] S () { s = 1; } // { dg-bogus "'S::S\\\(\\\)' is deprecated" } + S (int x) { s = x; } // { dg-warning "C\\\+\\\+11 attributes only available with" "" { target c++98_only } .-1 } + ~S () {} + int s; +}; + +int +main () +{ +} |