OSDN Git Service

gcc/
authorkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Feb 2004 21:43:18 +0000 (21:43 +0000)
committerkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Feb 2004 21:43:18 +0000 (21:43 +0000)
Remove -fwritable-strings.
* c-common.c (fix_string_type): Don't check
flag_writable_strings.
(fix_string_type): Likewise.
* c-opts.c (set_std_c89): Don't initialize
flag_writable_strings.
(set_std_c99): Likewise.
* common.opt (fwritable-strings): Remove.
* flags.h: Remove the external declaration of
flag_writable_strings.
* opts.c (common_handle_option) <OPT_fwritable_strings>:
Remove.
* toplev.c (flag_writable_strings): Remove.
(f_options): Remove an entry for writable-strings.
* varasm.c (const_hash_1) <STRING_CST>: Don't check
flag_writable_strings.
(compare_constant) <STRING_CST>: Likewise.
(build_constant_desc): Likewise.
* config/darwin.c (machopic_select_section): Likewise.
* config/arm/arm.c (AOF_ASSEMBLER): Likewise.
* config/arm/pe.c (arm_pe_encode_section_info): Likewise.
* config/iq2000/iq2000.c (iq2000_select_section): Likewise.
* config/mips/mips.c (mips_select_section): Likewise.
(mips_encode_section_info): Likewise.
* config/pa/pa.c (pa_select_section): Likewise.
* config/pa/pa.h (TEXT_SPACE_P): Likewise.
* config/v850/v850.c (v850_select_section): Likewise.
* doc/invoke.texi (-fwritable-strings): Remove.
(-fno-const-strings): Don't mention -fwritable-strings.
* doc/trouble.texi: Don't mention -fwritable-strings.

gcc/cp/
* decl.c (cxx_init_decl_processing): Don't check
flag_writable_strings.

gcc/testsuite/
* gcc.dg/fwritable-strings-1.c: Remove.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@78333 138bc75d-0d04-0410-961f-82ee72b054a4

22 files changed:
gcc/ChangeLog
gcc/c-common.c
gcc/c-opts.c
gcc/common.opt
gcc/config/arm/arm.c
gcc/config/arm/pe.c
gcc/config/darwin.c
gcc/config/iq2000/iq2000.c
gcc/config/mips/mips.c
gcc/config/pa/pa.c
gcc/config/pa/pa.h
gcc/config/v850/v850.c
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/doc/invoke.texi
gcc/doc/trouble.texi
gcc/flags.h
gcc/opts.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/fwritable-strings-1.c
gcc/toplev.c
gcc/varasm.c

index 8c624ea..79cf6b0 100644 (file)
@@ -1,3 +1,37 @@
+2004-02-23  Zack Weinberg  <zack@codesourcery.com>
+           Kazu Hirata  <kazu@cs.umass.edu>
+
+       Remove -fwritable-strings.
+       * c-common.c (fix_string_type): Don't check
+       flag_writable_strings.
+       (fix_string_type): Likewise.
+       * c-opts.c (set_std_c89): Don't initialize
+       flag_writable_strings.
+       (set_std_c99): Likewise.
+       * common.opt (fwritable-strings): Remove.
+       * flags.h: Remove the external declaration of
+       flag_writable_strings.
+       * opts.c (common_handle_option) <OPT_fwritable_strings>:
+       Remove.
+       * toplev.c (flag_writable_strings): Remove.
+       (f_options): Remove an entry for writable-strings.
+       * varasm.c (const_hash_1) <STRING_CST>: Don't check
+       flag_writable_strings.
+       (compare_constant) <STRING_CST>: Likewise.
+       (build_constant_desc): Likewise.
+       * config/darwin.c (machopic_select_section): Likewise.
+       * config/arm/arm.c (AOF_ASSEMBLER): Likewise.
+       * config/arm/pe.c (arm_pe_encode_section_info): Likewise.
+       * config/iq2000/iq2000.c (iq2000_select_section): Likewise.
+       * config/mips/mips.c (mips_select_section): Likewise.
+       (mips_encode_section_info): Likewise.
+       * config/pa/pa.c (pa_select_section): Likewise.
+       * config/pa/pa.h (TEXT_SPACE_P): Likewise.
+       * config/v850/v850.c (v850_select_section): Likewise.
+       * doc/invoke.texi (-fwritable-strings): Remove.
+       (-fno-const-strings): Don't mention -fwritable-strings.
+       * doc/trouble.texi: Don't mention -fwritable-strings.
+
 2003-02-23  Nathanael Nerode  <neroden@gcc.gnu.org>
 
        * doc/install.texi: Update for switch of boehm-gc to autoconf 2.57.
index 2ebb915..3d9dbfa 100644 (file)
@@ -1164,7 +1164,7 @@ fix_string_type (tree value)
      -Wwrite-strings says make the string constant an array of const char
      so that copying it to a non-const pointer will get a warning.
      For C++, this is the standard behavior.  */
-  if (flag_const_strings && ! flag_writable_strings)
+  if (flag_const_strings)
     {
       tree elements
        = build_type_variant (wide_flag ? wchar_type_node : char_type_node,
@@ -1179,7 +1179,7 @@ fix_string_type (tree value)
                          build_index_type (build_int_2 (nchars - 1, 0)));
 
   TREE_CONSTANT (value) = 1;
-  TREE_READONLY (value) = ! flag_writable_strings;
+  TREE_READONLY (value) = 1;
   TREE_STATIC (value) = 1;
   return value;
 }
index c9b34db..b4f3851 100644 (file)
@@ -1521,7 +1521,6 @@ set_std_c89 (int c94, int iso)
   flag_no_nonansi_builtin = iso;
   flag_isoc94 = c94;
   flag_isoc99 = 0;
-  flag_writable_strings = 0;
 }
 
 /* Set the C 99 standard (without GNU extensions if ISO).  */
@@ -1534,7 +1533,6 @@ set_std_c99 (int iso)
   flag_iso = iso;
   flag_isoc99 = 1;
   flag_isoc94 = 1;
-  flag_writable_strings = 0;
 }
 
 /* Set the C++ 98 standard (without GNU extensions if ISO).  */
index 8598d8c..cc7f218 100644 (file)
@@ -738,10 +738,6 @@ fwrapv
 Common
 Assume signed arithmetic overflow wraps around
 
-fwritable-strings
-Common
-Store strings in writable data section
-
 fzero-initialized-in-bss
 Common
 Put zero initialized data in the bss section
index 7ae5312..c774f19 100644 (file)
@@ -13948,8 +13948,7 @@ arm_encode_section_info (tree decl, rtx rtl, int first)
   /* This doesn't work with AOF syntax, since the string table may be in
      a different AREA.  */
 #ifndef AOF_ASSEMBLER
-  if (optimize > 0 && TREE_CONSTANT (decl)
-      && (!flag_writable_strings || TREE_CODE (decl) != STRING_CST))
+  if (optimize > 0 && TREE_CONSTANT (decl))
     SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
 #endif
 
index 2d38d1f..702ea3e 100644 (file)
@@ -213,8 +213,7 @@ arm_pe_encode_section_info (decl, rtl, first)
      int first ATTRIBUTE_UNUSED;
 {
   /* This bit is copied from arm_encode_section_info.  */
-  if (optimize > 0 && TREE_CONSTANT (decl)
-      && (!flag_writable_strings || TREE_CODE (decl) != STRING_CST))
+  if (optimize > 0 && TREE_CONSTANT (decl))
     SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
 
   /* Mark the decl so we can tell from the rtl whether the object is
index fd5d8b6..667c21e 100644 (file)
@@ -1215,8 +1215,7 @@ machopic_select_section (tree exp, int reloc,
 
   if (TREE_CODE (exp) == STRING_CST
       && ((size_t) TREE_STRING_LENGTH (exp)
-         == strlen (TREE_STRING_POINTER (exp)) + 1)
-      && ! flag_writable_strings)
+         == strlen (TREE_STRING_POINTER (exp)) + 1))
     cstring_section ();
   else if ((TREE_CODE (exp) == INTEGER_CST || TREE_CODE (exp) == REAL_CST)
           && flag_merge_constants)
index 90efc4b..55bda5f 100644 (file)
@@ -2623,15 +2623,13 @@ iq2000_select_section (tree decl, int reloc ATTRIBUTE_UNUSED,
     {
       /* For embedded applications, always put an object in read-only data
         if possible, in order to reduce RAM usage.  */
-      if (((TREE_CODE (decl) == VAR_DECL
-           && TREE_READONLY (decl) && !TREE_SIDE_EFFECTS (decl)
-           && DECL_INITIAL (decl)
-           && (DECL_INITIAL (decl) == error_mark_node
-               || TREE_CONSTANT (DECL_INITIAL (decl))))
-          /* Deal with calls from output_constant_def_contents.  */
-          || (TREE_CODE (decl) != VAR_DECL
-              && (TREE_CODE (decl) != STRING_CST
-                  || !flag_writable_strings))))
+      if ((TREE_CODE (decl) == VAR_DECL
+          && TREE_READONLY (decl) && !TREE_SIDE_EFFECTS (decl)
+          && DECL_INITIAL (decl)
+          && (DECL_INITIAL (decl) == error_mark_node
+              || TREE_CONSTANT (DECL_INITIAL (decl))))
+         /* Deal with calls from output_constant_def_contents.  */
+         || TREE_CODE (decl) != VAR_DECL)
        readonly_data_section ();
       else
        data_section ();
@@ -2640,15 +2638,13 @@ iq2000_select_section (tree decl, int reloc ATTRIBUTE_UNUSED,
     {
       /* For hosted applications, always put an object in small data if
         possible, as this gives the best performance.  */
-      if (((TREE_CODE (decl) == VAR_DECL
-                && TREE_READONLY (decl) && !TREE_SIDE_EFFECTS (decl)
-                && DECL_INITIAL (decl)
-                && (DECL_INITIAL (decl) == error_mark_node
-                    || TREE_CONSTANT (DECL_INITIAL (decl))))
-               /* Deal with calls from output_constant_def_contents.  */
-               || (TREE_CODE (decl) != VAR_DECL
-                   && (TREE_CODE (decl) != STRING_CST
-                       || !flag_writable_strings))))
+      if ((TREE_CODE (decl) == VAR_DECL
+          && TREE_READONLY (decl) && !TREE_SIDE_EFFECTS (decl)
+          && DECL_INITIAL (decl)
+          && (DECL_INITIAL (decl) == error_mark_node
+              || TREE_CONSTANT (DECL_INITIAL (decl))))
+         /* Deal with calls from output_constant_def_contents.  */
+         || TREE_CODE (decl) != VAR_DECL)
        readonly_data_section ();
       else
        data_section ();
index 88dca98..aba6639 100644 (file)
@@ -7283,8 +7283,7 @@ mips_select_section (tree decl, int reloc,
                     unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
 {
   if ((TARGET_EMBEDDED_PIC || TARGET_MIPS16)
-      && TREE_CODE (decl) == STRING_CST
-      && !flag_writable_strings)
+      && TREE_CODE (decl) == STRING_CST)
     /* For embedded position independent code, put constant strings in the
        text section, because the data section is limited to 64K in size.
        For mips16 code, put strings in the text section so that a PC
@@ -7366,7 +7365,6 @@ mips_encode_section_info (tree decl, rtx rtl, int first)
   if (TARGET_MIPS16)
     {
       if (first && TREE_CODE (decl) == STRING_CST
-          && ! flag_writable_strings
           /* If this string is from a function, and the function will
              go in a gnu linkonce section, then we can't directly
              access the string.  This gets an assembler error
@@ -7393,8 +7391,7 @@ mips_encode_section_info (tree decl, rtx rtl, int first)
         SYMBOL_REF_FLAG (symbol) = 1;
       else if (TREE_CODE (decl) == FUNCTION_DECL)
         SYMBOL_REF_FLAG (symbol) = 0;
-      else if (TREE_CODE (decl) == STRING_CST
-               && ! flag_writable_strings)
+      else if (TREE_CODE (decl) == STRING_CST)
         SYMBOL_REF_FLAG (symbol) = 0;
       else
         SYMBOL_REF_FLAG (symbol) = 1;
index 0f9a2db..e2074a1 100644 (file)
@@ -9076,7 +9076,6 @@ pa_select_section (tree exp, int reloc,
       && !reloc)
     readonly_data_section ();
   else if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'c'
-          && !(TREE_CODE (exp) == STRING_CST && flag_writable_strings)
           && !reloc)
     readonly_data_section ();
   else
index 3088425..b83acbc 100644 (file)
@@ -1666,8 +1666,7 @@ do {                                                                      \
        && TREE_READONLY (DECL) && ! TREE_SIDE_EFFECTS (DECL)           \
        && (! DECL_INITIAL (DECL) || ! reloc_needed (DECL_INITIAL (DECL))) \
        && !flag_pic)                                                   \
-   || (TREE_CODE_CLASS (TREE_CODE (DECL)) == 'c'                       \
-       && !(TREE_CODE (DECL) == STRING_CST && flag_writable_strings)))
+   || (TREE_CODE_CLASS (TREE_CODE (DECL)) == 'c'))
 
 #define FUNCTION_NAME_P(NAME)  (*(NAME) == '@')
 
index 08adab1..8337262 100644 (file)
@@ -3399,13 +3399,6 @@ v850_select_section (tree exp,
          break;
         }
     }
-  else if (TREE_CODE (exp) == STRING_CST)
-    {
-      if (! flag_writable_strings)
-       readonly_data_section ();
-      else
-       data_section ();
-    }
   else
     readonly_data_section ();
 }
index 3930fd4..875f7a5 100644 (file)
@@ -1,3 +1,9 @@
+2004-02-23  Zack Weinberg  <zack@codesourcery.com>
+           Kazu Hirata  <kazu@cs.umass.edu>
+
+       * decl.c (cxx_init_decl_processing): Don't check
+       flag_writable_strings.
+
 2004-02-23  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR c++/14156
index 1db274e..6a4d6ef 100644 (file)
@@ -3104,11 +3104,6 @@ cxx_init_decl_processing (void)
 
   /* Show we use EH for cleanups.  */
   using_eh_for_cleanups ();
-
-  /* Maintain consistency.  Perhaps we should just complain if they
-     say -fwritable-strings?  */
-  if (flag_writable_strings)
-    flag_const_strings = 0;
 }
 
 /* Generate an initializer for a function naming variable from
index 3a06239..b703dc3 100644 (file)
@@ -166,8 +166,7 @@ in the following sections.
 -trigraphs  -no-integrated-cpp  -traditional  -traditional-cpp @gol
 -fallow-single-precision  -fcond-mismatch @gol
 -fsigned-bitfields  -fsigned-char @gol
--funsigned-bitfields  -funsigned-char @gol
--fwritable-strings}
+-funsigned-bitfields  -funsigned-char}
 
 @item C++ Language Options
 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
@@ -1210,17 +1209,6 @@ These options control whether a bit-field is signed or unsigned, when the
 declaration does not use either @code{signed} or @code{unsigned}.  By
 default, such a bit-field is signed, because this is consistent: the
 basic integer types such as @code{int} are signed types.
-
-@item -fwritable-strings
-@opindex fwritable-strings
-Store string constants in the writable data segment and don't uniquize
-them.  This is for compatibility with old programs which assume they can
-write into string constants.
-
-Writing into string constants is a very bad idea; ``constants'' should
-be constant.
-
-This option is deprecated.
 @end table
 
 @node C++ Dialect Options
@@ -1292,8 +1280,7 @@ been added for putting variables into BSS without making them common.
 Give string constants type @code{char *} instead of type @code{const
 char *}.  By default, G++ uses type @code{const char *} as required by
 the standard.  Even if you use @option{-fno-const-strings}, you cannot
-actually modify the value of a string constant, unless you also use
-@option{-fwritable-strings}.
+actually modify the value of a string constant.
 
 This option might be removed in a future release of G++.  For maximum
 portability, you should structure your code so that it works with
index ce62c95..2af4525 100644 (file)
@@ -431,17 +431,14 @@ string its argument points to.
 @cindex @code{sscanf}, and constant strings
 @cindex @code{fscanf}, and constant strings
 @cindex @code{scanf}, and constant strings
-Another consequence is that @code{sscanf} does not work on some systems
-when passed a string constant as its format control string or input.
-This is because @code{sscanf} incorrectly tries to write into the string
-constant.  Likewise @code{fscanf} and @code{scanf}.
+Another consequence is that @code{sscanf} does not work on some very
+old systems when passed a string constant as its format control string
+or input.  This is because @code{sscanf} incorrectly tries to write
+into the string constant.  Likewise @code{fscanf} and @code{scanf}.
 
-@opindex fwritable-strings
-The best solution to these problems is to change the program to use
+The solution to these problems is to change the program to use
 @code{char}-array variables with initialization strings for these
-purposes instead of string constants.  But if this is not possible,
-you can use the @option{-fwritable-strings} flag, which directs GCC
-to handle string constants the same way most C compilers do.
+purposes instead of string constants.
 
 @item
 @code{-2147483648} is positive.
index 626993f..81793a8 100644 (file)
@@ -317,11 +317,6 @@ extern int flag_cse_skip_blocks;
    perform miscellaneous relatively-expensive optimizations.  */
 extern int flag_expensive_optimizations;
 
-/* Nonzero for -fwritable-strings:
-   store string constants in data segment and don't uniquize them.  */
-
-extern int flag_writable_strings;
-
 /* Nonzero means don't put addresses of constant functions in registers.
    Used for compiling the Unix kernel, where strange substitutions are
    done on the assembly output.  */
index a83357b..a4267f8 100644 (file)
@@ -1455,10 +1455,6 @@ common_handle_option (size_t scode, const char *arg,
       flag_wrapv = value;
       break;
 
-    case OPT_fwritable_strings:
-      flag_writable_strings = value;
-      break;
-
     case OPT_fzero_initialized_in_bss:
       flag_zero_initialized_in_bss = value;
       break;
index b912032..f608919 100644 (file)
@@ -1,3 +1,8 @@
+2004-02-23  Zack Weinberg  <zack@codesourcery.com>
+           Kazu Hirata  <kazu@cs.umass.edu>
+
+       * gcc.dg/fwritable-strings-1.c: Remove.
+
 2004-02-23  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR c/14156
index 652a084..e69de29 100644 (file)
@@ -1,18 +0,0 @@
-/* PR c/12818 */
-/* Origin: <fnf@ninemoons.com> */
-
-/* { dg-do run } */
-/* { dg-options "-fwritable-strings" } */
-/* { dg-error "-fwritable-strings is deprecated" "" { target *-*-* } 0 } */
-
-extern void abort(void);
-
-char *names[] = {"alice", "bob", "john"};
-
-int main (void)
-{
-  if (names[1][0] != 'b')
-    abort();
-
-  return 0;
-}
index 071fb5d..9e10d01 100644 (file)
@@ -582,11 +582,6 @@ int flag_reduce_all_givs = 0;
 
 int flag_regmove = 0;
 
-/* Nonzero for -fwritable-strings:
-   store string constants in data segment and don't uniquize them.  */
-
-int flag_writable_strings = 0;
-
 /* Nonzero means don't put addresses of constant functions in registers.
    Used for compiling the Unix kernel, where strange substitutions are
    done on the assembly output.  */
@@ -1076,7 +1071,6 @@ static const lang_independent_options f_options[] =
   {"prefetch-loop-arrays", &flag_prefetch_loop_arrays, 1 },
   {"move-all-movables", &flag_move_all_movables, 1 },
   {"reduce-all-givs", &flag_reduce_all_givs, 1 },
-  {"writable-strings", &flag_writable_strings, 1 },
   {"peephole", &flag_no_peephole, 0 },
   {"force-mem", &flag_force_mem, 1 },
   {"force-addr", &flag_force_addr, 1 },
index 806224d..061cbca 100644 (file)
@@ -2029,16 +2029,8 @@ const_hash_1 (const tree exp)
       return real_hash (TREE_REAL_CST_PTR (exp));
 
     case STRING_CST:
-      if (flag_writable_strings)
-       {
-         p = (char *) &exp;
-         len = sizeof exp;
-       }
-      else
-       {
-         p = TREE_STRING_POINTER (exp);
-         len = TREE_STRING_LENGTH (exp);
-       }
+      p = TREE_STRING_POINTER (exp);
+      len = TREE_STRING_LENGTH (exp);
       break;
 
     case COMPLEX_CST:
@@ -2154,9 +2146,6 @@ compare_constant (const tree t1, const tree t2)
       return REAL_VALUES_IDENTICAL (TREE_REAL_CST (t1), TREE_REAL_CST (t2));
 
     case STRING_CST:
-      if (flag_writable_strings)
-       return t1 == t2;
-
       if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2)))
        return 0;
 
@@ -2359,10 +2348,7 @@ build_constant_desc (tree exp)
   struct constant_descriptor_tree *desc;
 
   desc = ggc_alloc (sizeof (*desc));
-  if (flag_writable_strings && TREE_CODE (exp) == STRING_CST)
-    desc->value = exp;
-  else
-    desc->value = copy_constant (exp);
+  desc->value = copy_constant (exp);
 
   /* Create a string containing the label name, in LABEL.  */
   labelno = const_labelno++;
@@ -2444,9 +2430,9 @@ maybe_output_constant_def_contents (struct constant_descriptor_tree *desc,
     /* Already output; don't do it again.  */
     return;
 
-  /* The only constants that cannot safely be deferred, assuming the
-     context allows it, are strings under flag_writable_strings.  */
-  if (defer && (TREE_CODE (exp) != STRING_CST || !flag_writable_strings))
+  /* We can always defer constants as long as the context allows
+     doing so.  */
+  if (defer)
     {
       /* Increment n_deferred_constants if it exists.  It needs to be at
         least as large as the number of constants actually referred to
@@ -4486,7 +4472,7 @@ default_select_section (tree decl, int reloc,
        readonly = true;
     }
   else if (TREE_CODE (decl) == STRING_CST)
-    readonly = !flag_writable_strings;
+    readonly = true;
   else if (! (flag_pic && reloc))
     readonly = true;
 
@@ -4544,12 +4530,7 @@ categorize_decl_for_section (tree decl, int reloc, int shlib)
   if (TREE_CODE (decl) == FUNCTION_DECL)
     return SECCAT_TEXT;
   else if (TREE_CODE (decl) == STRING_CST)
-    {
-      if (flag_writable_strings)
-       return SECCAT_DATA;
-      else
-       return SECCAT_RODATA_MERGE_STR;
-    }
+    return SECCAT_RODATA_MERGE_STR;
   else if (TREE_CODE (decl) == VAR_DECL)
     {
       if (DECL_INITIAL (decl) == NULL