aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2015-05-22 09:07:31 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2015-05-22 09:07:31 +0000
commitfd5c817a2457050649c2aadd8657091b2f6bbdaf (patch)
tree28c0b41bb4cb2b1945924c7e303895d48ba4b7e4 /gcc/c
parentafbe632536736558f24680aa2c4c00b2d451e0b6 (diff)
downloadgcc-fd5c817a2457050649c2aadd8657091b2f6bbdaf.zip
gcc-fd5c817a2457050649c2aadd8657091b2f6bbdaf.tar.gz
gcc-fd5c817a2457050649c2aadd8657091b2f6bbdaf.tar.bz2
re PR c/47043 (allow deprecating enum values)
PR c/47043 * c-common.c (handle_deprecated_attribute): Allow CONST_DECL. * c-parser.c (c_parser_enum_specifier): Parse and apply enumerator attributes. * cp-tree.h (build_enumerator): Update declaration. * decl.c (build_enumerator): Add attributes parameter. Call cplus_decl_attributes. * init.c (constant_value_1): Pass tf_none to mark_used. * parser.c (cp_parser_enumerator_definition): Parse attributes and pass them down to build_enumerator. * pt.c (tsubst_enum): Pass decl attributes to build_enumerator. * semantics.c (finish_id_expression): Don't warn_deprecated_use here. * doc/extend.texi (Enumerator Attributes): New section. Document syntax of enumerator attributes. * c-c++-common/attributes-enum-1.c: New test. * c-c++-common/attributes-enum-2.c: New test. * g++.dg/cpp0x/attributes-enum-1.C: New test. * g++.dg/cpp1y/attributes-enum-1.C: New test. Co-Authored-By: Edward Smith-Rowland <3dw4rd@verizon.net> From-SVN: r223527
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-parser.c13
2 files changed, 18 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 59da72d..8af417b 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2015-05-22 Marek Polacek <polacek@redhat.com>
+
+ PR c/47043
+ * c-parser.c (c_parser_enum_specifier): Parse and apply enumerator
+ attributes.
+
2015-05-21 Marek Polacek <polacek@redhat.com>
* c-typeck.c (inform_declaration): Use DECL_IS_BUILTIN instead of
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index f496733..965b4b9 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -2516,6 +2516,13 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
enumerator:
enumeration-constant
enumeration-constant = constant-expression
+
+ GNU Extensions:
+
+ enumerator:
+ enumeration-constant attributes[opt]
+ enumeration-constant attributes[opt] = constant-expression
+
*/
static struct c_typespec
@@ -2575,6 +2582,8 @@ c_parser_enum_specifier (c_parser *parser)
c_parser_set_source_position_from_token (token);
decl_loc = value_loc = token->location;
c_parser_consume_token (parser);
+ /* Parse any specified attributes. */
+ tree enum_attrs = c_parser_attributes (parser);
if (c_parser_next_token_is (parser, CPP_EQ))
{
c_parser_consume_token (parser);
@@ -2584,7 +2593,9 @@ 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);
+ if (enum_attrs)
+ decl_attributes (&TREE_PURPOSE (enum_decl), enum_attrs, 0);
TREE_CHAIN (enum_decl) = values;
values = enum_decl;
seen_comma = false;