On Tue, Dec 17, 2024 at 05:40:15PM -0500, Jason Merrill wrote:
> > --- gcc/cp/tree.cc.jj       2024-08-15 22:23:07.908239976 +0200
> > +++ gcc/cp/tree.cc  2024-08-30 13:15:26.863829810 +0200
> > @@ -5087,6 +5087,25 @@ handle_likeliness_attribute (tree *node,
> >       return error_mark_node;
> >   }
> > +/* The C++14 [[deprecated]] attribute mostly maps to the GNU deprecated
> > +   attribute.  */
> > +
> > +static tree
> > +handle_std_deprecated_attribute (tree *node, tree name, tree args, int 
> > flags,
> > +                            bool *no_add_attrs)
> > +{
> > +  tree t = *node;
> > +  tree ret = handle_deprecated_attribute (node, name, args, flags,
> > +                                     no_add_attrs);
> > +  if (TYPE_P (*node) && t != *node)
> > +    pedwarn (input_location, OPT_Wattributes,
> > +        "%qE on a type other than class or enumeration definition", name);
> > +  else if (TREE_CODE (*node) == FIELD_DECL && DECL_UNNAMED_BIT_FIELD 
> > (*node))
> > +    pedwarn (input_location, OPT_Wattributes, "%qE on unnamed bit-field",
> > +        name);
> 
> Why not warn about these for the GNU deprecated attribute as well?

Do you mean both, or just unnamed bit-fields?

The first check would flag something that is used in the wild, e.g.
g++.dg/Wmissing-attributes.C
gcc.dg/gnu23-attrs-2.c
g++.dg/cpp0x/gen-attrs-81.C
g++.dg/warn/Wdangling-reference17.C
g++.dg/warn/Wdangling-reference20.C
tests would be affected by it (at least if pedantic), including
<exception> header which uses this on
  /// If you write a replacement %unexpected handler, it must be of this type.
  typedef void (*_GLIBCXX11_DEPRECATED unexpected_handler) ();
(not to mention the diagnostic wording is C++ish).
E.g. gnu23-attrs-2.c has
typedef int A[2];
__typeof__ (int [[gnu::deprecated]]) var1; /* { dg-warning "deprecated" } */
__typeof__ (A [[gnu::deprecated]]) var2; /* { dg-warning "deprecated" } */
__typeof__ (int [3] [[gnu::deprecated]]) var3; /* { dg-warning "deprecated" } */
tests.

The unnamed bit-field case is something I don't see used in our testsuite
from quick skimming, though we've accepted __attribute__((deprecated)) on
those for the last 22 years, so I was just trying to be safe and emit the
pedantic diagnostics only where the standard says it is invalid.

        Jakub

Reply via email to