]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c-common.h (flag_const_strings): Don't declare.
authorGabriel Dos Reis <gdr@integrable-solutions.net>
Thu, 9 Feb 2006 16:28:26 +0000 (16:28 +0000)
committerGabriel Dos Reis <gdr@gcc.gnu.org>
Thu, 9 Feb 2006 16:28:26 +0000 (16:28 +0000)
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.

cp/
2006-02-09  Gabriel Dos Reis  <gdr@integrable-solutions.net>

        * typeck.c (string_conv_p): Don't test for flag_const_strings.

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

From-SVN: r110804

gcc/ChangeLog
gcc/c-common.c
gcc/c-opts.c
gcc/c.opt
gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.benjamin/15351-1.C [deleted file]
gcc/testsuite/g++.old-deja/g++.benjamin/15351-2.C [deleted file]

index f3835d88c4d917150b239a92343f698c330965dd..ae18ebd6b5159c782379fd5624743484420eb5cf 100644 (file)
@@ -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.
index 5be3363521651df1dfe6147d20248a87457d6d0f..4c10bf4dd815aa04a3a3994d005b1fe37993abfd 100644 (file)
@@ -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;
index 34fc6b9b0adda0a7182fd7d4eb449c07017d5f05..90862f6b0bbacd382c6837925020c6a8c774b277 100644 (file)
@@ -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;
index a841d5281326052c1d3f565a178079d5231bfecf..34739c63c06bf259cb3e8f27e6aeb6d27b1e386b 100644 (file)
--- 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
index 74071c91e904a7d784c44eb46a3fedbec0463f2e..e3ceaa2240104024e46e1ba7b8ae8021dfbd3193 100644 (file)
@@ -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
index e8dac530a6fc5bb19c7b36d60e83aae2685bd204..df4f6cc7f5e2930b8f274782f5d6d018fee08c3d 100644 (file)
@@ -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);
index 798d4e79cbb2aef6936b88a31073d24ce1190c43..1cbbcbdaa0d1b8c508afdd686053d32bf5bd2028 100644 (file)
@@ -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
index d7ea0007e4841836903b86748900b7580072b5df..9ba4259cafa967fdb147c76f202ebcdf02522020 100644 (file)
@@ -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 (file)
index ca52343..0000000
+++ /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 (file)
index 931f50f..0000000
+++ /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;
-}
-