summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/c-common.c19
-rw-r--r--gcc/c-opts.c10
-rw-r--r--gcc/c.opt4
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/typeck.c2
-rw-r--r--gcc/doc/invoke.texi13
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.old-deja/g++.benjamin/15351-1.C28
-rw-r--r--gcc/testsuite/g++.old-deja/g++.benjamin/15351-2.C28
10 files changed, 31 insertions, 92 deletions
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 <gdr@integrable-solutions.net>
+
+ * 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 <OPT_fconst_strings>.
+ <OPT_Wwrite_strings>: 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 <richard.earnshaw@arm.com>
* 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=<name> Use class <name> 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 <gdr@integrable-solutions.net>
+
+ * typeck.c (string_conv_p): Don't test for flag_const_strings.
+
2006-02-08 Jason Merrill <jason@redhat.com>
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 <gdr@integrable-solutions.net>
+
+ * g++.old-deja/g++.benjamin/15351-2.C: Likewise.
+ * g++.old-deja/g++.benjamin/15351-1.C: Remove.
+
2006-02-09 Andrew Pinski <pinskia@physics.uc.edu>
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 <assert.h>
-
-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 <assert.h>
-
-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;
-}
-