aboutsummaryrefslogtreecommitdiff
path: root/gcc/varasm.c
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1992-03-28 01:19:16 +0000
committerRichard Stallman <rms@gnu.org>1992-03-28 01:19:16 +0000
commiteb528802e2c72e16ff4fef016f77ad7bc6bc06c7 (patch)
tree2f0e86cb0b8587fbecaed044f6b3fd4da85dfe3f /gcc/varasm.c
parent11030a604b97b88d30a15173946a966628451155 (diff)
downloadgcc-eb528802e2c72e16ff4fef016f77ad7bc6bc06c7.zip
gcc-eb528802e2c72e16ff4fef016f77ad7bc6bc06c7.tar.gz
gcc-eb528802e2c72e16ff4fef016f77ad7bc6bc06c7.tar.bz2
*** empty log message ***
From-SVN: r605
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r--gcc/varasm.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 306cc8c..ffd0f2c 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;