diff options
author | Jason Merrill <jason@redhat.com> | 2016-04-25 13:21:49 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2016-04-25 13:21:49 -0400 |
commit | d067e05f0e9a765e9ce60938aac1a1c99701cc33 (patch) | |
tree | 264530e0fbdd09de1ee921078acbe9204f96ca60 /gcc/c-family/c-lex.c | |
parent | 4dfaa9631958d036d4de44ebfa5a1bcfa92462c4 (diff) |
Implement C++17 [[maybe_unused]] attribute.
gcc/
* attribs.c (register_scoped_attributes): Fix logic.
* attribs.h: Declare register_scoped_attributes.
c-family/
* c-common.c (handle_unused_attribute): Accept CONST_DECL.
No longer static.
* c-common.h: Declare it.
* c-lex.c (c_common_has_attribute): Add maybe_unused.
cp/
* tree.c (std_attribute_table): New.
(init_tree): Register it.
From-SVN: r235414
Diffstat (limited to 'gcc/c-family/c-lex.c')
-rw-r--r-- | gcc/c-family/c-lex.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index 96da4fc974e..6b020a41e59 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -340,23 +340,26 @@ c_common_has_attribute (cpp_reader *pfile) attr_name = NULL_TREE; } } - } - if (attr_name) - { - init_attributes (); - const struct attribute_spec *attr = lookup_attribute_spec (attr_name); - if (attr) + else { - if (TREE_CODE (attr_name) == TREE_LIST) - attr_name = TREE_VALUE (attr_name); + /* Some standard attributes need special handling. */ if (is_attribute_p ("noreturn", attr_name)) result = 200809; else if (is_attribute_p ("deprecated", attr_name)) result = 201309; - else - result = 1; + else if (is_attribute_p ("maybe_unused", attr_name)) + result = 201603; + if (result) + attr_name = NULL_TREE; } } + if (attr_name) + { + init_attributes (); + const struct attribute_spec *attr = lookup_attribute_spec (attr_name); + if (attr) + result = 1; + } } else { |