aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorGeoffrey Keating <geoffk@apple.com>2004-01-16 07:20:38 +0000
committerGeoffrey Keating <geoffk@gcc.gnu.org>2004-01-16 07:20:38 +0000
commita6dd409400c73308da045537bb6ce4325b5fa3b9 (patch)
tree2bb0b3d31da2f2479b8780b6008c14e696427d17 /gcc/tree.c
parentb0fadda7ece3959434d698de5800c2ee95c215fd (diff)
downloadgcc-a6dd409400c73308da045537bb6ce4325b5fa3b9.zip
gcc-a6dd409400c73308da045537bb6ce4325b5fa3b9.tar.gz
gcc-a6dd409400c73308da045537bb6ce4325b5fa3b9.tar.bz2
Index: ChangeLog
2004-01-15 Geoffrey Keating <geoffk@apple.com> PR pch/13361 * c-typeck.c (constructor_asmspec): Delete. (struct initializer_stack): Delete field 'asmspec'. (start_init): Delete saving of asmspec. (finish_init): Don't update constructor_asmspec. * dwarf2out.c (rtl_for_decl_location): Duplicate string from tree. * stmt.c (expand_asm): Duplicate strings from tree. (expand_asm_operands): Likewise. * tree.c (tree_size): Update computation of size of STRING_CST. (make_node): Don't make STRING_CST nodes. (build_string): Allocate string with tree node. * tree.def (STRING_CST): Update comment. * tree.h (TREE_STRING_POINTER): Adjust for change to STRING_CST. (tree_string): Place contents of string in tree node. * config/sh/sh.c (sh_handle_sp_switch_attribute): Duplicate string from tree. Index: cp/ChangeLog 2004-01-15 Geoffrey Keating <geoffk@apple.com> PR pch/13361 * cp/lex.c (handle_pragma_interface): Duplicate string from tree. (handle_pragma_implementation): Likewise. Index: testsuite/ChangeLog 2004-01-15 Geoffrey Keating <geoffk@apple.com> PR pch/13361 * testsuite/g++.dg/pch/wchar-1.C: New. * testsuite/g++.dg/pch/wchar-1.Hs: New. From-SVN: r75961
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 8fffffd..da94c4a 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1,6 +1,6 @@
/* Language-independent node constructors for parse phase of GNU compiler.
Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GCC.
@@ -168,7 +168,8 @@ tree_size (tree node)
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);
+ case STRING_CST:
+ return sizeof (struct tree_string) + TREE_STRING_LENGTH (node);
default:
return (*lang_hooks.tree_size) (code);
}
@@ -212,8 +213,8 @@ make_node (enum tree_code code)
struct tree_common ttmp;
/* We can't allocate a TREE_VEC without knowing how many elements
- it will have. */
- if (code == TREE_VEC)
+ it will have; likewise a STRING_CST without knowing the length. */
+ if (code == TREE_VEC || code == STRING_CST)
abort ();
TREE_SET_CODE ((tree)&ttmp, code);
@@ -525,10 +526,23 @@ build_real_from_int_cst (tree type, tree i)
tree
build_string (int len, const char *str)
{
- tree s = make_node (STRING_CST);
+ tree s;
+ size_t length;
+
+ length = len + sizeof (struct tree_string);
+
+#ifdef GATHER_STATISTICS
+ tree_node_counts[(int) c_kind]++;
+ tree_node_sizes[(int) c_kind] += length;
+#endif
+
+ s = ggc_alloc_tree (length);
+ memset (s, 0, sizeof (struct tree_common));
+ TREE_SET_CODE (s, STRING_CST);
TREE_STRING_LENGTH (s) = len;
- TREE_STRING_POINTER (s) = ggc_alloc_string (str, len);
+ memcpy ((char *) TREE_STRING_POINTER (s), str, len);
+ ((char *) TREE_STRING_POINTER (s))[len] = '\0';
return s;
}