aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoffrey Keating <geoffk@apple.com>2004-01-16 07:20:38 +0000
committerGeoffrey Keating <geoffk@apple.com>2004-01-16 07:20:38 +0000
commit6baf48db4c91bbbc6069bcd4adf4d271208340da (patch)
tree2bb0b3d31da2f2479b8780b6008c14e696427d17
parent443f78346502dffef2eb5e781e7c666433ceb14b (diff)
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. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@75961 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog17
-rw-r--r--gcc/c-typeck.c13
-rw-r--r--gcc/config/sh/sh.c4
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/lex.c6
-rw-r--r--gcc/dwarf2out.c3
-rw-r--r--gcc/stmt.c17
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/pch/wchar-1.C1
-rw-r--r--gcc/testsuite/g++.dg/pch/wchar-1.Hs2
-rw-r--r--gcc/tree.c26
-rw-r--r--gcc/tree.def4
-rw-r--r--gcc/tree.h4
13 files changed, 74 insertions, 35 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6cdf24e0cae..35f3b982131 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,22 @@
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.
+
* config/rs6000/rs6000.c (rs6000_va_arg): No need to special-case
altivec operands.
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index ec00801a824..e8bec8f9b69 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -4304,9 +4304,6 @@ static int require_constant_elements;
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;
@@ -4378,7 +4375,6 @@ struct initializer_stack
{
struct initializer_stack *next;
tree decl;
- const char *asmspec;
struct constructor_stack *constructor_stack;
struct constructor_range_stack *constructor_range_stack;
tree elements;
@@ -4395,17 +4391,12 @@ struct initializer_stack *initializer_stack;
/* 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 = xmalloc (sizeof (struct initializer_stack));
- const char *asmspec = 0;
-
- if (asmspec_tree)
- asmspec = TREE_STRING_POINTER (asmspec_tree);
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;
@@ -4419,7 +4410,6 @@ start_init (tree decl, tree asmspec_tree, int top_level)
initializer_stack = p;
constructor_decl = decl;
- constructor_asmspec = asmspec;
constructor_designated = 0;
constructor_top_level = top_level;
@@ -4476,7 +4466,6 @@ finish_init (void)
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;
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index 43657e41e85..757f5aa1ee8 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -6774,8 +6774,8 @@ sh_handle_sp_switch_attribute (tree *node, tree name, tree args,
}
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;
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 43bd29d036c..f78d9af6f23 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+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.
+
2004-01-15 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR c++/9259
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index d22f5b063c1..4fb45280e2e 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -1,6 +1,6 @@
/* Separate lexical analyzer for GNU C++.
Copyright (C) 1987, 1989, 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.
Hacked by Michael Tiemann (tiemann@cygnus.com)
This file is part of GCC.
@@ -535,7 +535,7 @@ handle_pragma_interface (cpp_reader* dfile ATTRIBUTE_UNUSED )
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);
@@ -585,7 +585,7 @@ handle_pragma_implementation (cpp_reader* dfile ATTRIBUTE_UNUSED )
}
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);
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 1ee8f9fcde1..6e45394c0bb 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -9398,7 +9398,8 @@ rtl_for_decl_location (tree decl)
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
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 1a3d9188f30..6288341a48f 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -1,6 +1,6 @@
/* Expands front end tree to back end RTL for GCC
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
- 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GCC.
@@ -1106,7 +1106,8 @@ expand_asm (tree string, int vol)
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;
@@ -1668,7 +1669,7 @@ expand_asm_operands (tree string, tree outputs, tree inputs,
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.file, locus.line);
@@ -1749,7 +1750,8 @@ expand_asm_operands (tree string, tree outputs, tree inputs,
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;
@@ -1790,7 +1792,7 @@ expand_asm_operands (tree string, tree outputs, tree inputs,
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));
}
@@ -1818,8 +1820,9 @@ expand_asm_operands (tree string, tree outputs, tree inputs,
output_rtx[i],
gen_rtx_ASM_OPERANDS
(GET_MODE (output_rtx[i]),
- TREE_STRING_POINTER (string),
- constraints[i], i, argvec, constraintvec,
+ ggc_strdup (TREE_STRING_POINTER (string)),
+ ggc_strdup (constraints[i]),
+ i, argvec, constraintvec,
locus.file, locus.line));
MEM_VOLATILE_P (SET_SRC (XVECEXP (body, 0, i))) = vol;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c02a91a5513..196bce820a0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+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.
+
2004-01-15 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR c++/9259
diff --git a/gcc/testsuite/g++.dg/pch/wchar-1.C b/gcc/testsuite/g++.dg/pch/wchar-1.C
new file mode 100644
index 00000000000..6cb5fe15e4c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pch/wchar-1.C
@@ -0,0 +1 @@
+#include "wchar-1.H"
diff --git a/gcc/testsuite/g++.dg/pch/wchar-1.Hs b/gcc/testsuite/g++.dg/pch/wchar-1.Hs
new file mode 100644
index 00000000000..431908b88b1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pch/wchar-1.Hs
@@ -0,0 +1,2 @@
+#include <stddef.h>
+const wchar_t test_var[] = L"wide string";
diff --git a/gcc/tree.c b/gcc/tree.c
index 8fffffdca6d..da94c4a5893 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;
}
diff --git a/gcc/tree.def b/gcc/tree.def
index 0419faeaff0..48028ee351f 100644
--- a/gcc/tree.def
+++ b/gcc/tree.def
@@ -1,6 +1,6 @@
/* This file contains the definitions and documentation for the
tree codes used in GCC.
- Copyright (C) 1987, 1988, 1993, 1995, 1997, 1998, 2000, 2001
+ Copyright (C) 1987, 1988, 1993, 1995, 1997, 1998, 2000, 2001, 2004
Free Software Foundation, Inc.
This file is part of GCC.
@@ -274,7 +274,7 @@ DEFTREECODE (COMPLEX_CST, "complex_cst", 'c', 0)
/* Contents are in TREE_VECTOR_CST_ELTS field. */
DEFTREECODE (VECTOR_CST, "vector_cst", 'c', 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", 'c', 0)
/* Declarations. All references to names are represented as ..._DECL
diff --git a/gcc/tree.h b/gcc/tree.h
index 8f4334f0f58..7503fa5aaef 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -700,13 +700,13 @@ struct tree_real_cst GTY(())
/* 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. */