aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorJason Merrill <merrill@gnu.org>1996-12-09 22:31:23 +0000
committerJason Merrill <merrill@gnu.org>1996-12-09 22:31:23 +0000
commita94dbf2c2628c83773a1eb6c9ced1a49a3a5f45e (patch)
tree85d261767b8a92bfcd79dacffefca2f442d5cf06 /gcc/tree.c
parent19f5ce60f80423710b14e915da94b6f42ab25801 (diff)
downloadgcc-a94dbf2c2628c83773a1eb6c9ced1a49a3a5f45e.zip
gcc-a94dbf2c2628c83773a1eb6c9ced1a49a3a5f45e.tar.gz
gcc-a94dbf2c2628c83773a1eb6c9ced1a49a3a5f45e.tar.bz2
x
From-SVN: r13258
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 6a1e953..fde0e9d 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1268,6 +1268,45 @@ get_identifier (text)
return idp; /* <-- return if created */
}
+/* If an identifier with the name TEXT (a null-terminated string) has
+ previously been referred to, return that node; otherwise return
+ NULL_TREE. */
+
+tree
+maybe_get_identifier (text)
+ register char *text;
+{
+ register int hi;
+ register int i;
+ register tree idp;
+ register int len, hash_len;
+
+ /* Compute length of text in len. */
+ for (len = 0; text[len]; len++);
+
+ /* Decide how much of that length to hash on */
+ hash_len = len;
+ if (warn_id_clash && len > id_clash_len)
+ hash_len = id_clash_len;
+
+ /* Compute hash code */
+ hi = hash_len * 613 + (unsigned) text[0];
+ for (i = 1; i < hash_len; i += 2)
+ hi = ((hi * 613) + (unsigned) (text[i]));
+
+ hi &= (1 << HASHBITS) - 1;
+ hi %= MAX_HASH_TABLE;
+
+ /* Search table for identifier */
+ for (idp = hash_table[hi]; idp; idp = TREE_CHAIN (idp))
+ if (IDENTIFIER_LENGTH (idp) == len
+ && IDENTIFIER_POINTER (idp)[0] == text[0]
+ && !bcmp (IDENTIFIER_POINTER (idp), text, len))
+ return idp; /* <-- return if found */
+
+ return NULL_TREE;
+}
+
/* Enable warnings on similar identifiers (if requested).
Done after the built-in identifiers are created. */