]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Index: ChangeLog
authorGeoffrey Keating <geoffk@apple.com>
Fri, 16 Jan 2004 07:20:38 +0000 (07:20 +0000)
committerGeoffrey Keating <geoffk@gcc.gnu.org>
Fri, 16 Jan 2004 07:20:38 +0000 (07:20 +0000)
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

13 files changed:
gcc/ChangeLog
gcc/c-typeck.c
gcc/config/sh/sh.c
gcc/cp/ChangeLog
gcc/cp/lex.c
gcc/dwarf2out.c
gcc/stmt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pch/wchar-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/pch/wchar-1.Hs [new file with mode: 0644]
gcc/tree.c
gcc/tree.def
gcc/tree.h

index 6cdf24e0cae5d6ea2d12297eafc75a773964ebd4..35f3b982131f7caf89d4643fe3e0efa6b4b30b3f 100644 (file)
@@ -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.
 
index ec00801a824df32ca17210e8d75a4b3f24ea2771..e8bec8f9b69f62821a7e0b07c574e4021504a17b 100644 (file)
@@ -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;
index 43657e41e858de46c50fab355b15925256306008..757f5aa1ee829f82cc2fb463ccaa64e5572d69e4 100644 (file)
@@ -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;
index 43bd29d036c7480c3f5fa4bda2f4e0ccb1f15339..f78d9af6f230b546fa4d36c4a499d7d37accf7cb 100644 (file)
@@ -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
index d22f5b063c1d49c5dca8d33f05e070631a67ba40..4fb45280e2eef8582dc59aedc8291839cf420fcf 100644 (file)
@@ -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);
index 1ee8f9fcde19f062670896851ca5d47c6d78f8e5..6e45394c0bbf16f8906fe89ed60f49d7f0f72d5c 100644 (file)
@@ -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
index 1a3d9188f30cd4f5dc15c1e326e7f968ee2b1ae6..6288341a48f55f0ab02576389a317cb57fa9ee3d 100644 (file)
@@ -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;
index c02a91a551304194ffa8e9e4f08b305660c98334..196bce820a0738402c1231e07191c79ba2a4b296 100644 (file)
@@ -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 (file)
index 0000000..6cb5fe1
--- /dev/null
@@ -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 (file)
index 0000000..431908b
--- /dev/null
@@ -0,0 +1,2 @@
+#include <stddef.h>
+const wchar_t test_var[] = L"wide string";
index 8fffffdca6d3f98bf4491e7fb0941a97fc0878ed..da94c4a5893f14b1ac7202301edb3d4724b3d082 100644 (file)
@@ -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;
 }
index 0419faeaff028d85bb9ec3570a9254f7fc00759a..48028ee351f9d4730780c5209b5f38de9dff6e5f 100644 (file)
@@ -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
index 8f4334f0f58ea08aa47837fedf722de5b7d18539..7503fa5aaefc9cde1b812242bb45f5e251523804 100644 (file)
@@ -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.  */