aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/tree.c33
2 files changed, 31 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9d550ab..8c27493 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2004-12-02 Andrew Pinski <pinskia@physics.uc.edu>
+
+ * tree.c (is_attribute_p): Split out to ..
+ (is_attribute_with_length_p): Here. Use IDENTIFIER_LENGTH instead
+ of strlen and compare the string lengths before calling strcmp.
+ (lookup_attribute): Call is_attribute_with_length_p instead of
+ is_attribute_p.
+
2004-12-02 Devang Patel <dpatel@apple.com>
* config/darwin.h (TARGET_OPTION_TRANSLATE_TABLE): Add -gfull and -gused.
diff --git a/gcc/tree.c b/gcc/tree.c
index 961dfb8..843410b 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -3026,6 +3026,7 @@ build_type_attribute_variant (tree ttype, tree attribute)
return ttype;
}
+
/* Return nonzero if IDENT is a valid name for attribute ATTR,
or zero if not.
@@ -3034,21 +3035,21 @@ build_type_attribute_variant (tree ttype, tree attribute)
`text'. One might then also require attribute lists to be stored in
their canonicalized form. */
-int
-is_attribute_p (const char *attr, tree ident)
+static int
+is_attribute_with_length_p (const char *attr, int attr_len, tree ident)
{
- int ident_len, attr_len;
+ int ident_len;
const char *p;
if (TREE_CODE (ident) != IDENTIFIER_NODE)
return 0;
-
- if (strcmp (attr, IDENTIFIER_POINTER (ident)) == 0)
- return 1;
-
+
p = IDENTIFIER_POINTER (ident);
- ident_len = strlen (p);
- attr_len = strlen (attr);
+ ident_len = IDENTIFIER_LENGTH (ident);
+
+ if (ident_len == attr_len
+ && strcmp (attr, p) == 0)
+ return 1;
/* If ATTR is `__text__', IDENT must be `text'; and vice versa. */
if (attr[0] == '_')
@@ -3073,6 +3074,17 @@ is_attribute_p (const char *attr, tree ident)
return 0;
}
+/* Return nonzero if IDENT is a valid name for attribute ATTR,
+ or zero if not.
+
+ We try both `text' and `__text__', ATTR may be either one. */
+
+int
+is_attribute_p (const char *attr, tree ident)
+{
+ return is_attribute_with_length_p (attr, strlen (attr), ident);
+}
+
/* Given an attribute name and a list of attributes, return a pointer to the
attribute's list element if the attribute is part of the list, or NULL_TREE
if not found. If the attribute appears more than once, this only
@@ -3083,11 +3095,12 @@ tree
lookup_attribute (const char *attr_name, tree list)
{
tree l;
+ size_t attr_len = strlen (attr_name);
for (l = list; l; l = TREE_CHAIN (l))
{
gcc_assert (TREE_CODE (TREE_PURPOSE (l)) == IDENTIFIER_NODE);
- if (is_attribute_p (attr_name, TREE_PURPOSE (l)))
+ if (is_attribute_with_length_p (attr_name, attr_len, TREE_PURPOSE (l)))
return l;
}