]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree.c (tree_size): Revise expressions using TREE_CODE_LENGTH and TREE_VEC_LENGTH...
authorJohn David Anglin <dave@hiauly1.hia.nrc.ca>
Sat, 12 Oct 2002 18:08:37 +0000 (18:08 +0000)
committerJohn David Anglin <danglin@gcc.gnu.org>
Sat, 12 Oct 2002 18:08:37 +0000 (18:08 +0000)
* tree.c (tree_size): Revise expressions using TREE_CODE_LENGTH and
TREE_VEC_LENGTH to ensure values are promoted before doing subtraction.

From-SVN: r58089

gcc/ChangeLog
gcc/tree.c

index 4abfc248d4b691cc1e1f1c93c73c94ef19b338c9..6482378db6a9c914d32cfae9bcd62975e56fc0cf 100644 (file)
@@ -1,3 +1,8 @@
+2002-10-12  John David Anglin  <dave@hiauly1.hia.nrc.ca>
+
+       * tree.c (tree_size): Revise expressions using TREE_CODE_LENGTH and
+       TREE_VEC_LENGTH to ensure values are promoted before doing subtraction.
+
 2002-10-11  Janis Johnson  <janis187@us.ibm.com>
 
        * doc/compat.texi: Add info about C++ libraries.
index bd8938758fbe7015955d59343532cd9d3f5e4908..dd222a3b5df82af64eb7f61c30735d90263ed99e 100644 (file)
@@ -286,7 +286,7 @@ tree_size (node)
     case '1':  /* a unary arithmetic expression */
     case '2':  /* a binary arithmetic expression */
       return (sizeof (struct tree_exp)
-             + (TREE_CODE_LENGTH (code) - 1) * sizeof (char *));
+             + TREE_CODE_LENGTH (code) * sizeof (char *) - sizeof (char *));
 
     case 'c':  /* a constant */
       /* We can't use TREE_CODE_LENGTH for INTEGER_CST, since the number of
@@ -304,12 +304,12 @@ tree_size (node)
 
     case 'x':  /* something random, like an identifier.  */
       {
-         size_t length;
-         length = (sizeof (struct tree_common)
-                   + TREE_CODE_LENGTH (code) * sizeof (char *));
-         if (code == TREE_VEC)
-           length += (TREE_VEC_LENGTH (node) - 1) * sizeof (char *);
-         return length;
+       size_t length;
+       length = (sizeof (struct tree_common)
+                 + TREE_CODE_LENGTH (code) * sizeof (char *));
+       if (code == TREE_VEC)
+        length += TREE_VEC_LENGTH (node) * sizeof (char *) - sizeof (char *);
+       return length;
       }
 
     default: