https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101015

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This is because dump_decl does the decoration for TYPE_DECL_ALIAS_P:

1228       if (TYPE_DECL_ALIAS_P (t)
1229           && (flags & TFF_DECL_SPECIFIERS
1230               || flags & TFF_CLASS_KEY_OR_ENUM))
1231         {
1232           pp_cxx_ws_string (pp, "using");
1233           dump_decl (pp, DECL_NAME (t), flags);
1234           pp_cxx_whitespace (pp);
1235           pp_cxx_ws_string (pp, "=");
1236           pp_cxx_whitespace (pp);
1237           dump_type (pp, (DECL_ORIGINAL_TYPE (t)
1238                           ? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t)),
1239                      flags);

A way around it would be to disable TYPE_DECL_ALIAS_P temporarily for the
warning:

--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -5519,7 +5519,16 @@ cp_warn_deprecated_use (tree decl, tsubst_flags_t
complain)
    }
     }
   else
-    warned = warn_deprecated_use (decl, NULL_TREE);
+    {
+      // XXX alias_type_or_template_p?
+      const bool using_p = (TREE_CODE (decl) == TYPE_DECL
+               && TYPE_DECL_ALIAS_P (decl));
+      if (using_p)
+   TYPE_DECL_ALIAS_P (decl) = false;
+      warned = warn_deprecated_use (decl, NULL_TREE);
+      if (using_p)
+   TYPE_DECL_ALIAS_P (decl) = true;
+    }

   return warned;
 }

and then we get:

101015.C:7:8: warning: ‘A::bad’ is deprecated [-Wdeprecated-declarations]
    7 | A::bad j = 0;
      |        ^
101015.C:3:9: note: declared here
    3 |   using bad [[deprecated]] = int;
      |         ^~~

But maybe that's too ugly a hack.

Reply via email to