diff options
author | Martin Liska <mliska@suse.cz> | 2017-08-07 10:37:07 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2017-08-07 08:37:07 +0000 |
commit | 577eec5656925889d99c658de2a54ba8bd3ebf79 (patch) | |
tree | 1d346340abd66a2756508c28e25d2334f2e0a8da /gcc/attribs.h | |
parent | a5320f3ce2cfe8633a32730c3323238cbf673440 (diff) | |
download | gcc-577eec5656925889d99c658de2a54ba8bd3ebf79.tar.gz |
Canonicalize names of attributes.
2017-08-07 Martin Liska <mliska@suse.cz>
* attribs.h (canonicalize_attr_name): New function.
(cmp_attribs): Move from c-format.c and adjusted.
(is_attribute_p): Moved from tree.h.
* tree-inline.c: Add new includes.
* tree.c (cmp_attrib_identifiers): Use cmp_attribs.
(private_is_attribute_p): Remove.
(private_lookup_attribute): Likewise.
(private_lookup_attribute_by_prefix): Simplify.
(remove_attribute): Use is_attribute_p.
* tree.h: Remove removed declarations.
2017-08-07 Martin Liska <mliska@suse.cz>
* array-notation-common.c: Add new includes.
* c-format.c( handle_format_attribute): Canonicalize a format
function name.
* c-lex.c (c_common_has_attribute): Canonicalize name of an
attribute.
* c-pretty-print.c: Add new include.
2017-08-07 Martin Liska <mliska@suse.cz>
* parser.c (cp_parser_gnu_attribute_list): Canonicalize name of an
attribute.
(cp_parser_std_attribute): Likewise.
* tree.c: Add new include.
2017-08-07 Martin Liska <mliska@suse.cz>
* c-parser.c (c_parser_attributes): Canonicalize name of an
attribute.
2017-08-07 Martin Liska <mliska@suse.cz>
* go-gcc.cc (Gcc_backend::function): Look up for no_split_stack
and not __no_split_stack__.
2017-08-07 Martin Liska <mliska@suse.cz>
* g++.dg/cpp0x/pr65558.C: Update scanned pattern.
* gcc.dg/parm-impl-decl-1.c: Likewise.
* gcc.dg/parm-impl-decl-3.c: Likewise.
* gcc.dg/Wattributes-5.c: New test.
From-SVN: r250911
Diffstat (limited to 'gcc/attribs.h')
-rw-r--r-- | gcc/attribs.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gcc/attribs.h b/gcc/attribs.h index 7f13332700e..d4a790bb753 100644 --- a/gcc/attribs.h +++ b/gcc/attribs.h @@ -47,4 +47,47 @@ extern char *make_unique_name (tree, const char *, bool); extern tree make_dispatcher_decl (const tree); extern bool is_function_default_version (const tree); +/* For a given IDENTIFIER_NODE, strip leading and trailing '_' characters + so that we have a canonical form of attribute names. */ + +static inline tree +canonicalize_attr_name (tree attr_name) +{ + const size_t l = IDENTIFIER_LENGTH (attr_name); + const char *s = IDENTIFIER_POINTER (attr_name); + + if (l > 4 && s[0] == '_' && s[1] == '_' && s[l - 1] == '_' && s[l - 2] == '_') + return get_identifier_with_length (s + 2, l - 4); + + return attr_name; +} + +/* Compare attribute identifiers ATTR1 and ATTR2 with length ATTR1_LEN and + ATTR2_LEN. */ + +static inline bool +cmp_attribs (const char *attr1, size_t attr1_len, + const char *attr2, size_t attr2_len) +{ + return attr1_len == attr2_len && strncmp (attr1, attr2, attr1_len) == 0; +} + +/* Compare attribute identifiers ATTR1 and ATTR2. */ + +static inline bool +cmp_attribs (const char *attr1, const char *attr2) +{ + return cmp_attribs (attr1, strlen (attr1), attr2, strlen (attr2)); +} + +/* Given an identifier node IDENT and a string ATTR_NAME, return true + if the identifier node is a valid attribute name for the string. */ + +static inline bool +is_attribute_p (const char *attr_name, const_tree ident) +{ + return cmp_attribs (attr_name, strlen (attr_name), + IDENTIFIER_POINTER (ident), IDENTIFIER_LENGTH (ident)); +} + #endif // GCC_ATTRIBS_H |