This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C/C++ PATCH to allow deprecating enum values (PR c/47043)
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Wed, 6 May 2015 16:13:05 +0000
- Subject: Re: C/C++ PATCH to allow deprecating enum values (PR c/47043)
- Authentication-results: sourceware.org; auth=none
- References: <20150506154837 dot GW3384 at redhat dot com>
On Wed, 6 May 2015, Marek Polacek wrote:
> 2015-05-06 Marek Polacek <polacek@redhat.com>
>
> PR c/47043
> * c-common.c (handle_deprecated_attribute): Allow CONST_DECL.
Do all other attributes already reject CONST_DECL? I don't see any tests
for unsupported attributes on enum values being properly diagnosed (adding
tests for every unsupported attribute would seem excessive, but there
should be a few).
> diff --git gcc/c/c-parser.c gcc/c/c-parser.c
> index bf0e4c57..f06a6b3 100644
> --- gcc/c/c-parser.c
> +++ gcc/c/c-parser.c
> @@ -2584,7 +2584,11 @@ c_parser_enum_specifier (c_parser *parser)
> else
> enum_value = NULL_TREE;
> enum_decl = build_enumerator (decl_loc, value_loc,
> - &the_enum, enum_id, enum_value);
> + &the_enum, enum_id, enum_value);
> + /* Parse any specified attributes. */
> + tree enum_attrs = c_parser_attributes (parser);
> + if (enum_attrs)
> + decl_attributes (&TREE_PURPOSE (enum_decl), enum_attrs, 0);
You need to update the syntax comment to include the new syntax. You also
need to update the user documentation of attributes (syntax and semantics)
in extend.texi to include this case.
Why is the attribute going after the "= value"? That seems inconsistent
with positioning of attributes in initialized variable declarations, for
example.
--
Joseph S. Myers
joseph@codesourcery.com