From fd5c817a2457050649c2aadd8657091b2f6bbdaf Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Fri, 22 May 2015 09:07:31 +0000 Subject: 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 --- gcc/testsuite/c-c++-common/attributes-enum-1.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/attributes-enum-1.c (limited to 'gcc/testsuite/c-c++-common/attributes-enum-1.c') diff --git a/gcc/testsuite/c-c++-common/attributes-enum-1.c b/gcc/testsuite/c-c++-common/attributes-enum-1.c new file mode 100644 index 0000000..cb5af5b --- /dev/null +++ b/gcc/testsuite/c-c++-common/attributes-enum-1.c @@ -0,0 +1,22 @@ +/* Test enumerators with attributes. */ +/* PR c/47043 */ +/* { dg-do compile } */ + +enum E { + A __attribute__((deprecated)), + B __attribute__((deprecated ("foo"))), + C __attribute__((deprecated)) = 10, + D __attribute__((deprecated ("foo"))) = 15, + E +}; + +int +f (int i) +{ + i += A; /* { dg-warning ".A. is deprecated" } */ + i += B; /* { dg-warning ".B. is deprecated" } */ + i += C; /* { dg-warning ".C. is deprecated" } */ + i += D; /* { dg-warning ".D. is deprecated" } */ + i += E; + return i; +} -- cgit v1.1