aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorJason Merrill <jason@gcc.gnu.org>1998-08-23 22:08:45 -0400
committerJason Merrill <jason@gcc.gnu.org>1998-08-23 22:08:45 -0400
commitd9cf7c824593edf5fba4c00f41eaa1e791855c3e (patch)
treea665b0240e32b8e9553746924e2725aa56002700 /gcc/c-common.c
parentdf44f2b0e98dccd15796b2e9af364c1704fba95e (diff)
downloadgcc-d9cf7c824593edf5fba4c00f41eaa1e791855c3e.zip
gcc-d9cf7c824593edf5fba4c00f41eaa1e791855c3e.tar.gz
gcc-d9cf7c824593edf5fba4c00f41eaa1e791855c3e.tar.bz2
c-common.c (combine_strings): Also set TREE_READONLY.
* c-common.c (combine_strings): Also set TREE_READONLY. Change warn_write_strings to flag_const_strings. * c-decl.c, c-tree.h: Likewise. cp/ * tree.c (lvalue_type): Fix for arrays. * typeck.c (string_conv_p): New fn. (convert_for_assignment): Use it. (build_unary_op): Use lvalue_type. * call.c (standard_conversion, convert_like): Use string_conv_p. (add_function_candidate): Use lvalue_type. * cvt.c (convert_to_reference): Likewise. * decl2.c (lang_decode_option): Ignore -traditional. * decl.c (init_decl_processing): flag_writable_strings inhibits flag_const_strings. * lang-options.h (lang_options): Add fconst-strings to the list of valid options. * decl2.c (lang_f_options, lang_decode_option): Likewise. From-SVN: r21928
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 9e45067..8916958 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -298,7 +298,6 @@ combine_strings (strings)
value = make_node (STRING_CST);
TREE_STRING_POINTER (value) = p;
TREE_STRING_LENGTH (value) = length;
- TREE_CONSTANT (value) = 1;
}
else
{
@@ -313,8 +312,9 @@ combine_strings (strings)
/* Create the array type for the string constant.
-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. */
- if (warn_write_strings
+ 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_traditional && ! flag_writable_strings))
{
tree elements
@@ -328,7 +328,8 @@ combine_strings (strings)
TREE_TYPE (value)
= build_array_type (wide_flag ? wchar_type_node : char_type_node,
build_index_type (build_int_2 (nchars - 1, 0)));
- TREE_CONSTANT (value) = 1;
+
+ TREE_READONLY (value) = TREE_CONSTANT (value) = ! flag_writable_strings;
TREE_STATIC (value) = 1;
return value;
}