From cfb10bd3bad0636ed13ee47ffa9571287ee2d8d8 Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis Date: Thu, 9 Feb 2006 16:28:26 +0000 Subject: [PATCH] c-common.h (flag_const_strings): Don't declare. 2006-02-09 Gabriel Dos Reis * c-common.h (flag_const_strings): Don't declare. * c-common.c (flag_const_strings): Remove. * c.opt (fconst_strings): Remove. * c-opts.c (c_common_handle_option): Remove * . : Don't set flag_const_strings. (c_common_init_options): Don't set flag_const_strings. * doc/invoke.texi (-fno-const-strings): Remove documentation. cp/ 2006-02-09 Gabriel Dos Reis * typeck.c (string_conv_p): Don't test for flag_const_strings. testsuite/ 2006-02-09 Gabriel Dos Reis * g++.old-deja/g++.benjamin/15351-2.C: Likewise. * g++.old-deja/g++.benjamin/15351-1.C: Remove. From-SVN: r110804 --- gcc/ChangeLog | 10 ++++++++ gcc/c-common.c | 19 ++++++++------- gcc/c-opts.c | 10 +------- gcc/c.opt | 4 ---- gcc/cp/ChangeLog | 4 ++++ gcc/cp/typeck.c | 2 +- gcc/doc/invoke.texi | 13 +---------- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.old-deja/g++.benjamin/15351-1.C | 28 ----------------------- gcc/testsuite/g++.old-deja/g++.benjamin/15351-2.C | 28 ----------------------- 10 files changed, 31 insertions(+), 92 deletions(-) delete mode 100644 gcc/testsuite/g++.old-deja/g++.benjamin/15351-1.C delete mode 100644 gcc/testsuite/g++.old-deja/g++.benjamin/15351-2.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f3835d88c4d..ae18ebd6b51 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2006-02-09 Gabriel Dos Reis + + * c-common.h (flag_const_strings): Don't declare. + * c-common.c (flag_const_strings): Remove. + * c.opt (fconst_strings): Remove. + * c-opts.c (c_common_handle_option): Remove . + : Don't set flag_const_strings. + (c_common_init_options): Don't set flag_const_strings. + * doc/invoke.texi (-fno-const-strings): Remove documentation. + 2006-02-09 Richard Earnshaw * arm.md (tlobits_cbranch): New pattern. diff --git a/gcc/c-common.c b/gcc/c-common.c index 5be33635216..4c10bf4dd81 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -261,11 +261,6 @@ int flag_ms_extensions; int flag_no_asm; -/* Nonzero means give string constants the type `const char *', as mandated - by the standard. */ - -int flag_const_strings; - /* Nonzero means to treat bitfields as signed unless they say `unsigned'. */ int flag_signed_bitfields = 1; @@ -869,10 +864,14 @@ fix_string_type (tree value) nchars - 1, nchars_max, relevant_std); } - /* Create the array type for the string constant. flag_const_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. + /* Create the array type for the string constant. The ISO C++ + standard says that a string literal has type `const char[N]' or + `const wchar_t[N]'. We use the same logic when invoked as a C + front-end with -Wwrite-strings. + ??? We should change the type of an expression depending on the + state of a warning flag. We should just be warning -- see how + this is handled in the C++ front-end for the deprecated implicit + conversion from string literals to `char*' or `wchar_t*'. The C++ front end relies on TYPE_MAIN_VARIANT of a cv-qualified array type being the unqualified version of that type. @@ -883,7 +882,7 @@ fix_string_type (tree value) e_type = wide_flag ? wchar_type_node : char_type_node; i_type = build_index_type (build_int_cst (NULL_TREE, nchars - 1)); a_type = build_array_type (e_type, i_type); - if (flag_const_strings) + if (c_dialect_cxx() || warn_write_strings) a_type = c_build_qualified_type (a_type, TYPE_QUAL_CONST); TREE_TYPE (value) = a_type; diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 34fc6b9b0ad..90862f6b0bb 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -225,7 +225,6 @@ c_common_init_options (unsigned int argc, const char **argv) before passing on command-line options to cpplib. */ cpp_opts->warn_dollars = 0; - flag_const_strings = c_dialect_cxx (); flag_exceptions = c_dialect_cxx (); warn_pointer_arith = c_dialect_cxx (); @@ -531,10 +530,7 @@ c_common_handle_option (size_t scode, const char *arg, int value) break; case OPT_Wwrite_strings: - if (!c_dialect_cxx ()) - flag_const_strings = value; - else - warn_write_strings = value; + warn_write_strings = value; break; case OPT_Weffc__: @@ -652,10 +648,6 @@ c_common_handle_option (size_t scode, const char *arg, int value) flag_conserve_space = value; break; - case OPT_fconst_strings: - flag_const_strings = value; - break; - case OPT_fconstant_string_class_: constant_string_class_name = arg; break; diff --git a/gcc/c.opt b/gcc/c.opt index a841d528132..34739c63c06 100644 --- a/gcc/c.opt +++ b/gcc/c.opt @@ -469,10 +469,6 @@ fconserve-space C++ ObjC++ Reduce the size of object files -fconst-strings -C++ ObjC++ -Make string literals \"const char[]\" not \"char[]\" - fconstant-string-class= ObjC ObjC++ Joined -fconst-string-class= Use class for constant strings diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 74071c91e90..e3ceaa22401 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2006-02-09 Gabriel Dos Reis + + * typeck.c (string_conv_p): Don't test for flag_const_strings. + 2006-02-08 Jason Merrill PR c++/25979 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index e8dac530a6f..df4f6cc7f5e 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1472,7 +1472,7 @@ string_conv_p (tree totype, tree exp, int warn) { tree t; - if (! flag_const_strings || TREE_CODE (totype) != POINTER_TYPE) + if (TREE_CODE (totype) != POINTER_TYPE) return 0; t = TREE_TYPE (totype); diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 798d4e79cbb..1cbbcbdaa0d 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -175,7 +175,7 @@ in the following sections. @item C++ Language Options @xref{C++ Dialect Options,,Options Controlling C++ Dialect}. @gccoptlist{-fabi-version=@var{n} -fno-access-control -fcheck-new @gol --fconserve-space -ffriend-injection -fno-const-strings @gol +-fconserve-space -ffriend-injection @gol -fno-elide-constructors @gol -fno-enforce-eh-specs @gol -ffor-scope -fno-for-scope -fno-gnu-keywords @gol @@ -1450,17 +1450,6 @@ earlier releases. This option is for compatibility, and may be removed in a future release of G++. -@item -fno-const-strings -@opindex fno-const-strings -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. - -This option might be removed in a future release of G++. For maximum -portability, you should structure your code so that it works with -string constants that have type @code{const char *}. - @item -fno-elide-constructors @opindex fno-elide-constructors The C++ standard allows an implementation to omit creating a temporary diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d7ea0007e48..9ba4259cafa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-02-09 Gabriel Dos Reis + + * g++.old-deja/g++.benjamin/15351-2.C: Likewise. + * g++.old-deja/g++.benjamin/15351-1.C: Remove. + 2006-02-09 Andrew Pinski PR tree-opt/26179 diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/15351-1.C b/gcc/testsuite/g++.old-deja/g++.benjamin/15351-1.C deleted file mode 100644 index ca52343b3f6..00000000000 --- a/gcc/testsuite/g++.old-deja/g++.benjamin/15351-1.C +++ /dev/null @@ -1,28 +0,0 @@ -// { dg-do run } -// { dg-options "-fno-const-strings" } -// 981203 bkoz -// g++/15351 - test - -#include - -bool gtest; - -struct acapulco { - acapulco(const char *) { gtest = false; } - acapulco(char *) { gtest = true; } -}; - -void foo(void) -{ - acapulco("some such string\n"); -} - -int main() -{ - foo(); - if (!gtest) - assert (0); - - return !gtest; -} - diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/15351-2.C b/gcc/testsuite/g++.old-deja/g++.benjamin/15351-2.C deleted file mode 100644 index 931f50f6235..00000000000 --- a/gcc/testsuite/g++.old-deja/g++.benjamin/15351-2.C +++ /dev/null @@ -1,28 +0,0 @@ -// { dg-do run } -// { dg-options "-fconst-strings" } -// 981203 bkoz -// g++/15351 + test - -#include - -bool gtest; - -struct acapulco { - acapulco(const char *) { gtest = true; } - acapulco(char *) { gtest = false; } -}; - -void foo(void) -{ - acapulco("some such string\n"); -} - -int main() -{ - foo(); - if (!gtest) - assert (0); - - return !gtest; -} - -- 2.11.4.GIT