diff options
author | Zack Weinberg <zack@gcc.gnu.org> | 2003-04-07 06:03:17 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2003-04-07 06:03:17 +0000 |
commit | d78e771d468c7280b95c7dbbafcdd87d69357d80 (patch) | |
tree | 85a5a4cad3cfe432c546c4df2134dac37924265c /gcc/tree.c | |
parent | a9c89a57f64d057fac96a9bbdbcde6ba7656ad55 (diff) | |
download | gcc-d78e771d468c7280b95c7dbbafcdd87d69357d80.zip gcc-d78e771d468c7280b95c7dbbafcdd87d69357d80.tar.gz gcc-d78e771d468c7280b95c7dbbafcdd87d69357d80.tar.bz2 |
tree.c (tree_size): For all 'c' and 'x' nodes...
* tree.c (tree_size): For all 'c' and 'x' nodes, look directly
at the sizes of the relevant structures, rather than relying
on TREE_CODE_LENGTH. Call lang_hooks.tree_size to get the
sizes of any such we don't know about. Use
lang_hooks.identifier_size for IDENTIFIER_NODE.
(initializer_zerop): Use CONSTRUCTOR_ELTS.
* tree.def: Update commentary. Make fourth element of
the definition for all 'c' and 'x' nodes zero.
* langhooks.h: New hook, tree_size / LANG_HOOKS_TREE_SIZE.
* langhooks-def.h: Update to match.
* langhooks.c: New default, lhd_tree_size.
* c-common.def (SRCLOC): Kill.
* c-pretty-print.c (pp_c_postfix_expression [case SRCLOC]):
Remove entirely - was already #if-ed out.
ada:
* ada-tree.def: Make fourth element for GNAT_LOOP_ID zero.
* misc.c (gnat_tree_size): New function.
(LANG_HOOKS_TREE_SIZE): Override.
cp:
* cp-tree.def: Make fourth element for all 'c' and 'x' nodes zero.
* cp-lang.c (cp_tree_size): New function.
(LANG_HOOKS_TREE_SIZE): Override.
* cp-tree.h (SOURCE_LOCUS, SRCLOC_FILE, SRCLOC_LINE, struct
tree_srcloc, TS_CP_COMMON, TS_CP_SRCLOC): Kill.
(union lang_tree_node): Remove common and srcloc members.
(build_srcloc_here): Don't prototype.
* decl.c (cp_tree_node_structure): Kill SRCLOC case.
* pt.c (pending_templates): Correct comment.
* tree.c (build_srcloc, build_srcloc_here): Kill.
From-SVN: r65323
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 46 |
1 files changed, 25 insertions, 21 deletions
@@ -182,28 +182,32 @@ tree_size (node) + 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 - words is machine-dependent due to varying length of HOST_WIDE_INT, - which might be wider than a pointer (e.g., long long). Similarly - for REAL_CST, since the number of words is machine-dependent due - to varying size and alignment of `double'. */ - if (code == INTEGER_CST) - return sizeof (struct tree_int_cst); - else if (code == REAL_CST) - return sizeof (struct tree_real_cst); - else - return (sizeof (struct tree_common) - + TREE_CODE_LENGTH (code) * sizeof (char *)); + switch (code) + { + case INTEGER_CST: return sizeof (struct tree_int_cst); + case REAL_CST: return sizeof (struct tree_real_cst); + case COMPLEX_CST: return sizeof (struct tree_complex); + case VECTOR_CST: return sizeof (struct tree_vector); + case STRING_CST: return sizeof (struct tree_string); + default: + return (*lang_hooks.tree_size) (code); + } 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) * sizeof (char *) - sizeof (char *); - return length; - } + switch (code) + { + case IDENTIFIER_NODE: return lang_hooks.identifier_size; + case TREE_LIST: return sizeof (struct tree_list); + case TREE_VEC: return (sizeof (struct tree_vec) + + TREE_VEC_LENGTH(node) * sizeof(char *) + - sizeof (char *)); + + case ERROR_MARK: + case PLACEHOLDER_EXPR: return sizeof (struct tree_common); + + default: + return (*lang_hooks.tree_size) (code); + } default: abort (); @@ -4817,7 +4821,7 @@ initializer_zerop (init) { if (AGGREGATE_TYPE_P (TREE_TYPE (init))) { - tree aggr_init = TREE_OPERAND (init, 1); + tree aggr_init = CONSTRUCTOR_ELTS (init); while (aggr_init) { |