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
+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.
-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,
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;
}
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). */
flag_iso = iso;
flag_isoc99 = 1;
flag_isoc94 = 1;
- flag_writable_strings = 0;
}
/* Set the C++ 98 standard (without GNU extensions if ISO). */
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
/* 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
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
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)
{
/* 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 ();
{
/* 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 ();
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
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
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;
&& !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
&& 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) == '@')
break;
}
}
- else if (TREE_CODE (exp) == STRING_CST)
- {
- if (! flag_writable_strings)
- readonly_data_section ();
- else
- data_section ();
- }
else
readonly_data_section ();
}
+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
/* 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
-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}.
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
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
@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.
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. */
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;
+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
-/* 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;
-}
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. */
{"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 },
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:
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;
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++;
/* 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
readonly = true;
}
else if (TREE_CODE (decl) == STRING_CST)
- readonly = !flag_writable_strings;
+ readonly = true;
else if (! (flag_pic && reloc))
readonly = true;
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