From eb528802e2c72e16ff4fef016f77ad7bc6bc06c7 Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Sat, 28 Mar 1992 01:19:16 +0000 Subject: [PATCH] *** empty log message *** From-SVN: r605 --- gcc/varasm.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/gcc/varasm.c b/gcc/varasm.c index 306cc8ccf3e..ffd0f2c0533 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1545,11 +1545,14 @@ const_hash (exp) /* For record type, include the type in the hashing. We do not do so for array types because (1) the sizes of the elements are sufficient - and (2) distinct array types can have the same constructor. */ + and (2) distinct array types can have the same constructor. + Instead, we include the array size because the constructor could + be shorter. */ if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE) hi = ((int) TREE_TYPE (exp) & ((1 << HASHBITS) - 1)) % MAX_HASH_TABLE; else - hi = 5; + hi = ((5 + int_size_in_bytes (TREE_TYPE (exp))) + & ((1 << HASHBITS) - 1)) % MAX_HASH_TABLE; for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) hi = (hi * 603 + const_hash (TREE_VALUE (link))) % MAX_HASH_TABLE; @@ -1678,6 +1681,15 @@ compare_constant_1 (exp, p) return 0; p += sizeof type; + /* For arrays, insist that the size in bytes match. */ + if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE) + { + int size = int_size_in_bytes (TREE_TYPE (exp)); + if (bcmp (&size, p, sizeof size)) + return 0; + p += sizeof size; + } + for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) if ((p = compare_constant_1 (TREE_VALUE (link), p)) == 0) return 0; @@ -1792,6 +1804,13 @@ record_constant_1 (exp) type = 0; obstack_grow (&permanent_obstack, (char *) &type, sizeof type); + /* For arrays, insist that the size in bytes match. */ + if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE) + { + int size = int_size_in_bytes (TREE_TYPE (exp)); + obstack_grow (&permanent_obstack, (char *) &size, sizeof size); + } + for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) record_constant_1 (TREE_VALUE (link)); return; -- 2.30.2