From: John David Anglin Date: Sat, 12 Oct 2002 18:08:37 +0000 (+0000) Subject: tree.c (tree_size): Revise expressions using TREE_CODE_LENGTH and TREE_VEC_LENGTH... X-Git-Tag: releases/gcc-3.2.1~168 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=425c0b1d15a2fad41028f28464250598ffaeddc6;p=thirdparty%2Fgcc.git tree.c (tree_size): Revise expressions using TREE_CODE_LENGTH and TREE_VEC_LENGTH to ensure values... * 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4abfc248d4b6..6482378db6a9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2002-10-12 John David Anglin + + * 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 * doc/compat.texi: Add info about C++ libraries. diff --git a/gcc/tree.c b/gcc/tree.c index bd8938758fbe..dd222a3b5df8 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -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: