On 9/13/24 6:17 AM, Jakub Jelinek wrote:
Hi!

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).

Bootstrapped/regtested on x86_64-linux and i686-linux and tested with
a cross compiler to x86_64-mingw on the testcase, ok for trunk?
OK.

2024-09-13  Jakub Jelinek  <ja...@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.

--- gcc/cp/optimize.cc.jj       2024-05-21 10:19:34.484528180 +0200
+++ gcc/cp/optimize.cc  2024-09-12 13:56:30.710186354 +0200
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.
  #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))
      {
--- gcc/testsuite/g++.dg/warn/deprecated-20.C.jj        2024-09-12 
13:54:58.850422325 +0200
+++ gcc/testsuite/g++.dg/warn/deprecated-20.C   2024-09-12 13:55:27.510036714 
+0200
@@ -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 ()
+{
+}

        Jakub


Reply via email to