Remove -fwritable-strings.

gcc/
	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.

Co-Authored-By: Kazu Hirata <kazu@cs.umass.edu>

From-SVN: r78333
This commit is contained in:
Zack Weinberg 2004-02-23 21:43:18 +00:00 committed by Kazu Hirata
parent eac8a696d5
commit 3521b33c2f
22 changed files with 83 additions and 136 deletions

View 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.

View 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;
}

View 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). */

View 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

View 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

View 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

View 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)

View 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 ();

View 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;

View 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

View 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) == '@')

View 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 ();
}

View 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

View 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

View 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

View 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.

View 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. */

View 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;

View 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

View 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;
}

View 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 },

View 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