This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC 3.4 Release Status (2003-12-16)


Mark Mitchell <mark@codesourcery.com> writes:

> Do we still need -fwritable-strings?  We have a 3.4 regression with
> that option, and I would prefer just to remove the option, since we're
> moving away from supporting traditional C anyhow.

Conveniently, I already have a patch to remove -fwritable-strings.
It's old and will require updating, but here it is anyway, just to
demonstrate how many places have gotten infiltrated by this thing.

zw

===================================================================
Index: c-common.c
--- c-common.c	14 Apr 2003 03:13:03 -0000	1.410
+++ c-common.c	16 Dec 2003 17:53:35 -0000
@@ -1208,7 +1208,7 @@ fix_string_type (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,
@@ -1223,7 +1223,7 @@ fix_string_type (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: c-opts.c
--- c-opts.c	20 Mar 2003 16:46:17 -0000	1.40
+++ c-opts.c	16 Dec 2003 17:53:35 -0000
@@ -1874,7 +1874,6 @@ set_std_c89 (c94, iso)
   flag_noniso_default_format_attributes = !iso;
   flag_isoc94 = c94;
   flag_isoc99 = 0;
-  flag_writable_strings = 0;
 }
 
 /* Set the C 99 standard (without GNU extensions if ISO).  */
@@ -1889,7 +1888,6 @@ set_std_c99 (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: flags.h
--- flags.h	26 Apr 2003 15:19:05 -0000	1.106
+++ flags.h	16 Dec 2003 17:53:35 -0000
@@ -316,11 +316,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: toplev.c
--- toplev.c	26 Apr 2003 15:19:05 -0000	1.746
+++ toplev.c	16 Dec 2003 17:53:36 -0000
@@ -561,11 +561,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.  */
@@ -1053,8 +1048,6 @@ static const lang_independent_options f_
    N_("Force all loop invariant computations out of loops") },
   {"reduce-all-givs", &flag_reduce_all_givs, 1,
    N_("Strength reduce all loop general induction variables") },
-  {"writable-strings", &flag_writable_strings, 1,
-   N_("Store strings in writable data section") },
   {"peephole", &flag_no_peephole, 0,
    N_("Enable machine specific peephole optimizations") },
   {"force-mem", &flag_force_mem, 1,
===================================================================
Index: varasm.c
--- varasm.c	27 Apr 2003 03:50:27 -0000	1.343
+++ varasm.c	16 Dec 2003 17:53:36 -0000
@@ -2347,9 +2347,6 @@ compare_constant (t1, t2)
       return REAL_VALUES_IDENTICAL (TREE_REAL_CST (t1), TREE_REAL_CST (t2));
 
     case STRING_CST:
-      if (flag_writable_strings)
-	return 0;
-
       if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2)))
 	return 0;
 
@@ -2665,7 +2662,7 @@ maybe_output_constant_def_contents (exp,
 
   label = XSTR (XEXP (rtl, 0), 0);
 
-  if (defer && TREE_CODE (exp) == STRING_CST && !flag_writable_strings)
+  if (defer && TREE_CODE (exp) == STRING_CST)
     {
       struct deferred_string **defstr;
       defstr = (struct deferred_string **)
@@ -4923,7 +4920,7 @@ default_select_section (decl, reloc, ali
 	readonly = true;
     }
   else if (TREE_CODE (decl) == STRING_CST)
-    readonly = !flag_writable_strings;
+    readonly = true;
   else if (! (flag_pic && reloc))
     readonly = true;
 
@@ -4984,12 +4981,7 @@ categorize_decl_for_section (decl, reloc
   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
===================================================================
Index: config/darwin.c
--- config/darwin.c	20 Apr 2003 18:20:37 -0000	1.36
+++ config/darwin.c	16 Dec 2003 17:53:37 -0000
@@ -1153,10 +1153,8 @@ machopic_select_section (exp, reloc, ali
 {
   if (TREE_CODE (exp) == STRING_CST)
     {
-      if (flag_writable_strings)
-	data_section ();
-      else if ((size_t) TREE_STRING_LENGTH (exp) !=
-	       strlen (TREE_STRING_POINTER (exp)) + 1)
+      if ((size_t) TREE_STRING_LENGTH (exp) !=
+	  strlen (TREE_STRING_POINTER (exp)) + 1)
 	readonly_data_section ();
       else
 	cstring_section ();
===================================================================
Index: config/arm/arm.c
--- config/arm/arm.c	25 Apr 2003 15:24:30 -0000	1.270
+++ config/arm/arm.c	16 Dec 2003 17:53:38 -0000
@@ -12160,8 +12160,7 @@ arm_encode_section_info (decl, rtl, firs
   /* 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: config/arm/pe.c
--- config/arm/pe.c	20 Apr 2003 18:20:37 -0000	1.20
+++ config/arm/pe.c	16 Dec 2003 17:53:38 -0000
@@ -213,8 +213,7 @@ arm_pe_encode_section_info (decl, rtl, f
      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: config/m88k/m88k.c
--- config/m88k/m88k.c	20 Apr 2003 18:20:37 -0000	1.72
+++ config/m88k/m88k.c	16 Dec 2003 17:53:38 -0000
@@ -3280,14 +3280,7 @@ m88k_select_section (decl, reloc, align)
      unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
 {
   if (TREE_CODE (decl) == STRING_CST)
-    {
-      if (! flag_writable_strings)
-	readonly_data_section ();
-      else if (TREE_STRING_LENGTH (decl) <= m88k_gp_threshold)
-	sdata_section ();
-      else
-	data_section ();
-    }
+    readonly_data_section ();
   else if (TREE_CODE (decl) == VAR_DECL)
     {
       if (SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)))
@@ -3340,21 +3333,13 @@ m88k_encode_section_info (decl, rtl, fir
      rtx rtl;
      int first ATTRIBUTE_UNUSED;
 {
-  if (m88k_gp_threshold > 0)
+  if (m88k_gp_threshold > 0
+      && TREE_CODE (decl) == VAR_DECL
+      && (!TREE_READONLY (decl) || TREE_SIDE_EFFECTS (decl)))
     {
-      if (TREE_CODE (decl) == VAR_DECL)
-	{
-	  if (!TREE_READONLY (decl) || TREE_SIDE_EFFECTS (decl))
-	    {
-	      int size = int_size_in_bytes (TREE_TYPE (decl));
-
-	      if (size > 0 && size <= m88k_gp_threshold)
-		SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
-	    }
-	}
-      else if (TREE_CODE (decl) == STRING_CST
-	       && flag_writable_strings
-	       && TREE_STRING_LENGTH (decl) <= m88k_gp_threshold)
+      int size = int_size_in_bytes (TREE_TYPE (decl));
+      
+      if (size > 0 && size <= m88k_gp_threshold)
 	SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
     }
 }
===================================================================
Index: config/mips/mips.c
--- config/mips/mips.c	20 Apr 2003 18:20:38 -0000	1.256
+++ config/mips/mips.c	16 Dec 2003 17:53:39 -0000
@@ -8442,8 +8442,7 @@ mips_select_section (decl, reloc, align)
   int size = int_size_in_bytes (TREE_TYPE (decl));
 
   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
@@ -8454,15 +8453,11 @@ mips_select_section (decl, reloc, align)
       /* 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)))))
 	  && ! (flag_pic && reloc))
 	readonly_data_section ();
       else if (size > 0 && size <= mips_section_threshold)
@@ -8477,15 +8472,11 @@ mips_select_section (decl, reloc, align)
 
       if (size > 0 && size <= mips_section_threshold)
 	SMALL_DATA_SECTION ();
-      else 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)))
+      else 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)))))
 	       && ! (flag_pic && reloc))
 	readonly_data_section ();
       else
@@ -8529,7 +8520,6 @@ mips_encode_section_info (decl, rtl, fir
   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
@@ -8568,9 +8558,6 @@ mips_encode_section_info (decl, rtl, fir
 	SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
       else if (TREE_CODE (decl) == FUNCTION_DECL)
 	SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 0;
-      else if (TREE_CODE (decl) == STRING_CST
-	       && ! flag_writable_strings)
-	SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 0;
       else
 	SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
     }
@@ -10871,8 +10858,7 @@ mips_unique_section (decl, reloc)
            || DECL_INITIAL (decl) == error_mark_node)
     sec = 2;
   else 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
===================================================================
Index: config/pa/pa.c
--- config/pa/pa.c	20 Apr 2003 18:20:38 -0000	1.207
+++ config/pa/pa.c	16 Dec 2003 17:53:40 -0000
@@ -8507,7 +8507,6 @@ pa_select_section (exp, reloc, align)
       && !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: config/pa/pa.h
--- config/pa/pa.h	17 Apr 2003 23:18:57 -0000	1.189
+++ config/pa/pa.h	16 Dec 2003 17:53:41 -0000
@@ -1536,8 +1536,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: config/v850/v850.c
--- config/v850/v850.c	20 Apr 2003 18:20:39 -0000	1.75
+++ config/v850/v850.c	16 Dec 2003 17:53:41 -0000
@@ -3472,13 +3472,6 @@ v850_select_section (exp, reloc, align)
 	  break;
         }
     }
-  else if (TREE_CODE (exp) == STRING_CST)
-    {
-      if (! flag_writable_strings)
-	readonly_data_section ();
-      else
-	data_section ();
-    }
   else
     readonly_data_section ();
 }
===================================================================
Index: cp/decl.c
--- cp/decl.c	23 Apr 2003 16:27:25 -0000	1.1040
+++ cp/decl.c	16 Dec 2003 17:53:43 -0000
@@ -6355,11 +6355,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: doc/invoke.texi
--- doc/invoke.texi	24 Apr 2003 15:53:22 -0000	1.270
+++ doc/invoke.texi	16 Dec 2003 17:53:44 -0000
@@ -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}.
@@ -1227,14 +1226,6 @@ declaration does not use either @code{si
 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.
 @end table
 
 @node C++ Dialect Options
@@ -1305,8 +1296,7 @@ been added for putting variables into BS
 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: doc/trouble.texi
--- doc/trouble.texi	7 Feb 2003 23:12:03 -0000	1.15
+++ doc/trouble.texi	16 Dec 2003 17:53:44 -0000
@@ -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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]