invoke.texi (-Write-strings): Document that it is enabled by default.
authorGabriel Dos Reis <gdr@integrable-solutions.net>
Mon, 13 Feb 2006 01:57:29 +0000 (01:57 +0000)
committerGabriel Dos Reis <gdr@gcc.gnu.org>
Mon, 13 Feb 2006 01:57:29 +0000 (01:57 +0000)
2006-02-12  Gabriel Dos Reis  <gdr@integrable-solutions.net>

        * doc/invoke.texi (-Write-strings): Document that it is
enabled by
        default.
        * c.opt (-Wwrite-strings): Declare variable
warn_write_strings.
        Clarify documentation.
        * c-common.h (warn_write_strings): Remove.
        * c-common.c (warn_write_strings): Likewise.
        * c-opts.c (c_common_init_options): Enable -Wwrite-strings by
        default for C++.

testsuite/
2006-02-12  Gabriel Dos Reis  <gdr@integrable-solutions.net>

        * g++.dg/warn/no-write-strings.C: New test.
        * g++.dg/warn/write-strings.C: Likewise.
        * g++.dg/warn/write-strings-default.C: Likewise.

From-SVN: r110907

gcc/ChangeLog
gcc/c-common.c
gcc/c-common.h
gcc/c-opts.c
gcc/c.opt
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/no-write-strings.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/write-strings-default.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/write-strings.C [new file with mode: 0644]

index 18ea30d7b340406554c158da5ff1bbacb8b3d0fa..e5fa4c25b6d4a56cba9e893459f7871ebc32693b 100644 (file)
@@ -1,3 +1,14 @@
+2006-02-12  Gabriel Dos Reis  <gdr@integrable-solutions.net>
+
+       * doc/invoke.texi (-Write-strings): Document that it is enabled by
+       default. 
+       * c.opt (-Wwrite-strings): Declare variable warn_write_strings.
+       Clarify documentation.
+       * c-common.h (warn_write_strings): Remove.
+       * c-common.c (warn_write_strings): Likewise.
+       * c-opts.c (c_common_init_options): Enable -Wwrite-strings by
+       default for C++.
+
 2006-02-12  Roger Sayle  <roger@eyesopen.com>
 
        PR middle-end/25724
index 4c10bf4dd815aa04a3a3994d005b1fe37993abfd..759a68ce44e56784a9baf9be893302e2e1e00383 100644 (file)
@@ -265,11 +265,6 @@ int flag_no_asm;
 
 int flag_signed_bitfields = 1;
 
-/* Nonzero means warn about deprecated conversion from string constant to
-   `char *'.  */
-
-int warn_write_strings;
-
 /* Warn about #pragma directives that are not recognized.  */
 
 int warn_unknown_pragmas; /* Tri state variable.  */
index ba7dc5cf6e89e64b147c9682bd5fd21d65e20619..6498255aff873a666616c9a85fce04dac61c7a90 100644 (file)
@@ -406,11 +406,6 @@ extern int flag_const_strings;
 
 extern int flag_signed_bitfields;
 
-/* Nonzero means warn about deprecated conversion from string constant to
-   `char *'.  */
-
-extern int warn_write_strings;
-
 /* Warn about #pragma directives that are not recognized.  */      
 
 extern int warn_unknown_pragmas; /* Tri state variable.  */  
index 90862f6b0bbacd382c6837925020c6a8c774b277..00a8631e54453169ba38082f33ae4885f9b19439 100644 (file)
@@ -227,6 +227,7 @@ c_common_init_options (unsigned int argc, const char **argv)
 
   flag_exceptions = c_dialect_cxx ();
   warn_pointer_arith = c_dialect_cxx ();
+  warn_write_strings = c_dialect_cxx();
 
   deferred_opts = XNEWVEC (struct deferred_opt, argc);
 
index 34739c63c06bf259cb3e8f27e6aeb6d27b1e386b..8f58d3dca7e7aa70c8338be36bfb7df2af944afa 100644 (file)
--- a/gcc/c.opt
+++ b/gcc/c.opt
@@ -420,8 +420,8 @@ C ObjC C++ ObjC++
 Do not warn about using variadic macros when -pedantic
 
 Wwrite-strings
-C ObjC C++ ObjC++
-Give strings the type \"array of char\"
+C ObjC C++ ObjC++ Var(warn_write_strings)
+In C++, nonzero means warn about deprecated conversion from string literals to `char *'.  In C, similar warning, except that the conversion is of course not deprecated by the ISO C standard.
 
 Wpointer-sign
 C ObjC Var(warn_pointer_sign) Init(-1)
index 1384562b98560af8faace68710d51d9a33181bc9..6fb86e314e8ee7de176022048f0767fbdafe4606 100644 (file)
@@ -3065,7 +3065,8 @@ When compiling C, give string constants the type @code{const
 char[@var{length}]} so that
 copying the address of one into a non-@code{const} @code{char *}
 pointer will get a warning; when compiling C++, warn about the
-deprecated conversion from string constants to @code{char *}.
+deprecated conversion from string literals to @code{char *}.  This
+warning, by default, is enabled for C++ programs.
 These warnings will help you find at
 compile time code that can try to write into a string constant, but
 only if you have been very careful about using @code{const} in
index 845090db732d17fb503b508f294927cb63d67adc..686a2234ede4b56a5467c55430ac8daa9dc7ca96 100644 (file)
@@ -1,3 +1,9 @@
+2006-02-12  Gabriel Dos Reis  <gdr@integrable-solutions.net>
+
+       * g++.dg/warn/no-write-strings.C: New test.
+       * g++.dg/warn/write-strings.C: Likewise.
+       * g++.dg/warn/write-strings-default.C: Likewise.
+
 2006-02-12  Erik Edelmann  <eedelman@gcc.gnu.org>
 
        PR fortran/25806
diff --git a/gcc/testsuite/g++.dg/warn/no-write-strings.C b/gcc/testsuite/g++.dg/warn/no-write-strings.C
new file mode 100644 (file)
index 0000000..c5d48de
--- /dev/null
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options -Wno-write-strings }
+
+int main()
+{
+   char* p = "Asgaard";
+}
diff --git a/gcc/testsuite/g++.dg/warn/write-strings-default.C b/gcc/testsuite/g++.dg/warn/write-strings-default.C
new file mode 100644 (file)
index 0000000..234c473
--- /dev/null
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// Test the default for -Wwrite-strings
+
+int main()
+{
+   char* p = "Asgaard";         // { dg-warning "warning:.*deprecated.*" }
+}
diff --git a/gcc/testsuite/g++.dg/warn/write-strings.C b/gcc/testsuite/g++.dg/warn/write-strings.C
new file mode 100644 (file)
index 0000000..38233e0
--- /dev/null
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options -Wwrite-strings }
+
+int main()
+{
+   char* p = "Asgaard";         // { dg-warning "warning:.*deprecated.*" }
+}