This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C/C++ PATCH to allow deprecating enum values (PR c/47043)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]