+2004-09-17 Geoffrey Keating <geoffk@apple.com>
+
+ * tree-inline.c (copy_tree_r): Don't duplicate constants, they're
+ shared anyway.
+
+ 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_code_size): Clean up assertions, don't allow requests
+ for "the size of a STRING_CST".
+ * 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.
+
2004-09-17 Zack Weinberg <zack@codesourcery.com>
* Makefile.in (c-parse.o): Depend on $(C_PRAGMA_H).
such as (struct foo) {...}. */
static tree constructor_decl;
-/* start_init saves the ASMSPEC arg here for really_start_incremental_init. */
-static const char *constructor_asmspec;
-
/* Nonzero if this is an initializer for a top-level decl. */
static int constructor_top_level;
{
struct initializer_stack *next;
tree decl;
- const char *asmspec;
struct constructor_stack *constructor_stack;
struct constructor_range_stack *constructor_range_stack;
tree elements;
/* Prepare to parse and output the initializer for variable DECL. */
void
-start_init (tree decl, tree asmspec_tree, int top_level)
+start_init (tree decl, tree asmspec_tree ATTRIBUTE_UNUSED, int top_level)
{
const char *locus;
- struct initializer_stack *p = XNEW (struct initializer_stack);
- const char *asmspec = 0;
-
- if (asmspec_tree)
- asmspec = TREE_STRING_POINTER (asmspec_tree);
+ struct initializer_stack *p = xmalloc (sizeof (struct initializer_stack));
p->decl = constructor_decl;
- p->asmspec = constructor_asmspec;
p->require_constant_value = require_constant_value;
p->require_constant_elements = require_constant_elements;
p->constructor_stack = constructor_stack;
initializer_stack = p;
constructor_decl = decl;
- constructor_asmspec = asmspec;
constructor_designated = 0;
constructor_top_level = top_level;
free (spelling_base);
constructor_decl = p->decl;
- constructor_asmspec = p->asmspec;
require_constant_value = p->require_constant_value;
require_constant_elements = p->require_constant_elements;
constructor_stack = p->constructor_stack;
}
else
{
- sp_switch = gen_rtx_SYMBOL_REF (VOIDmode,
- TREE_STRING_POINTER (TREE_VALUE (args)));
+ char *s = ggc_strdup (TREE_STRING_POINTER (TREE_VALUE (args)));
+ sp_switch = gen_rtx_SYMBOL_REF (VOIDmode, s);
}
return NULL_TREE;
+2004-09-16 Geoffrey Keating <geoffk@apple.com>
+
+ PR pch/13361
+ * cp/lex.c (handle_pragma_interface): Duplicate string from tree.
+ (handle_pragma_implementation): Likewise.
+
2004-09-17 Jeffrey D. Oldham <oldham@codesourcery.com>
Zack Weinberg <zack@codesourcery.com>
else if (fname == 0)
main_filename = lbasename (input_filename);
else
- main_filename = TREE_STRING_POINTER (fname);
+ main_filename = ggc_strdup (TREE_STRING_POINTER (fname));
finfo = get_fileinfo (input_filename);
}
else
{
- main_filename = TREE_STRING_POINTER (fname);
+ main_filename = ggc_strdup (TREE_STRING_POINTER (fname));
if (cpp_included (parse_in, main_filename))
warning ("#pragma implementation for %s appears after file is included",
main_filename);
TREE_STRING_LENGTH (init) - 1) == 0
&& ((size_t) TREE_STRING_LENGTH (init)
== strlen (TREE_STRING_POINTER (init)) + 1))
- rtl = gen_rtx_CONST_STRING (VOIDmode, TREE_STRING_POINTER (init));
+ rtl = gen_rtx_CONST_STRING (VOIDmode,
+ ggc_strdup (TREE_STRING_POINTER (init)));
}
/* If the initializer is something that we know will expand into an
immediate RTL constant, expand it now. Expanding anything else
if (TREE_CODE (string) == ADDR_EXPR)
string = TREE_OPERAND (string, 0);
- body = gen_rtx_ASM_INPUT (VOIDmode, TREE_STRING_POINTER (string));
+ body = gen_rtx_ASM_INPUT (VOIDmode,
+ ggc_strdup (TREE_STRING_POINTER (string)));
MEM_VOLATILE_P (body) = vol;
body = gen_rtx_ASM_OPERANDS ((noutputs == 0 ? VOIDmode
: GET_MODE (output_rtx[0])),
- TREE_STRING_POINTER (string),
+ ggc_strdup (TREE_STRING_POINTER (string)),
empty_string, 0, argvec, constraintvec,
locus);
ASM_OPERANDS_INPUT (body, i) = op;
ASM_OPERANDS_INPUT_CONSTRAINT_EXP (body, i)
- = gen_rtx_ASM_INPUT (TYPE_MODE (type), constraints[i + noutputs]);
+ = gen_rtx_ASM_INPUT (TYPE_MODE (type),
+ ggc_strdup (constraints[i + noutputs]));
if (decl_conflicts_with_clobbers_p (val, clobbered_regs))
clobber_conflict_found = 1;
if (noutputs == 1 && nclobbers == 0)
{
- ASM_OPERANDS_OUTPUT_CONSTRAINT (body) = constraints[0];
+ ASM_OPERANDS_OUTPUT_CONSTRAINT (body) = ggc_strdup (constraints[0]);
emit_insn (gen_rtx_SET (VOIDmode, output_rtx[0], body));
}
output_rtx[i],
gen_rtx_ASM_OPERANDS
(GET_MODE (output_rtx[i]),
- TREE_STRING_POINTER (string),
- constraints[i], i, argvec, constraintvec,
- locus));
+ ggc_strdup (TREE_STRING_POINTER (string)),
+ ggc_strdup (constraints[i]),
+ i, argvec, constraintvec, locus));
MEM_VOLATILE_P (SET_SRC (XVECEXP (body, 0, i))) = vol;
}
+2004-09-16 Geoffrey Keating <geoffk@apple.com>
+
+ PR pch/13361
+ * testsuite/g++.dg/pch/wchar-1.C: New.
+ * testsuite/g++.dg/pch/wchar-1.Hs: New.
+
2004-09-17 Kenneth Zadeck <Kenneth.Zadeck@NaturalBridge.com>
* gcc.c-torture/execute/20040917-1.c: New test.
--- /dev/null
+#include "wchar-1.H"
--- /dev/null
+#include <stddef.h>
+const wchar_t test_var[] = L"wide string";
/* We make copies of most nodes. */
if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code))
- || TREE_CODE_CLASS (code) == tcc_constant
|| code == TREE_LIST
|| code == TREE_VEC
|| code == TYPE_DECL)
*walk_subtrees = 0;
else if (TREE_CODE_CLASS (code) == tcc_declaration)
*walk_subtrees = 0;
+ else if (TREE_CODE_CLASS (code) == tcc_constant)
+ *walk_subtrees = 0;
else
gcc_assert (code != STATEMENT_LIST);
return NULL_TREE;
return DECL_CHECK (decl)->decl.assembler_name;
}
-/* Compute the number of bytes occupied by a tree with code CODE. This
- function cannot be used for TREE_VEC or PHI_NODE codes, which are of
- variable length. */
+/* Compute the number of bytes occupied by a tree with code CODE.
+ This function cannot be used for TREE_VEC, PHI_NODE, or STRING_CST
+ codes, which are of variable length. */
size_t
tree_code_size (enum tree_code code)
{
- /* We can't state the size of a TREE_VEC or PHI_NODE
- without knowing how many elements it will have. */
- gcc_assert (code != TREE_VEC);
- gcc_assert (code != PHI_NODE);
-
switch (TREE_CODE_CLASS (code))
{
case tcc_declaration: /* A decl 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: gcc_unreachable ();
default:
return lang_hooks.tree_size (code);
}
case ERROR_MARK:
case PLACEHOLDER_EXPR: return sizeof (struct tree_common);
- case PHI_NODE:
+ case TREE_VEC:
+ case PHI_NODE: gcc_unreachable ();
case SSA_NAME: return sizeof (struct tree_ssa_name);
return (sizeof (struct tree_vec)
+ (TREE_VEC_LENGTH (node) - 1) * sizeof(char *));
+ case STRING_CST:
+ return sizeof (struct tree_string) + TREE_STRING_LENGTH (node) - 1;
+
default:
return tree_code_size (code);
}
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;
}
/* Contents are in TREE_VECTOR_CST_ELTS field. */
DEFTREECODE (VECTOR_CST, "vector_cst", tcc_constant, 0)
-/* Contents are TREE_STRING_LENGTH and TREE_STRING_POINTER fields. */
+/* Contents are TREE_STRING_LENGTH and the actual contents of the string. */
DEFTREECODE (STRING_CST, "string_cst", tcc_constant, 0)
/* Declarations. All references to names are represented as ..._DECL
/* In a STRING_CST */
#define TREE_STRING_LENGTH(NODE) (STRING_CST_CHECK (NODE)->string.length)
-#define TREE_STRING_POINTER(NODE) (STRING_CST_CHECK (NODE)->string.pointer)
+#define TREE_STRING_POINTER(NODE) (STRING_CST_CHECK (NODE)->string.str)
struct tree_string GTY(())
{
struct tree_common common;
int length;
- const char *pointer;
+ const char str[1];
};
/* In a COMPLEX_CST node. */