re PR c++/79791 (-Werror=write-strings ignored with -Wpedantic)
authorMarek Polacek <polacek@redhat.com>
Fri, 3 Mar 2017 09:58:10 +0000 (09:58 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 3 Mar 2017 09:58:10 +0000 (09:58 +0000)
PR c++/79791
* typeck.c (string_conv_p): In C++11, always call pedwarn with
OPT_Wwrite_strings.

* g++.dg/warn/Wwrite-strings-1.C: New test.
* g++.dg/warn/Wwrite-strings-2.C: New test.
* g++.dg/warn/Wwrite-strings-3.C: New test.
* g++.dg/warn/Wwrite-strings-4.C: New test.
* g++.dg/warn/Wwrite-strings-5.C: New test.
* g++.dg/warn/Wwrite-strings-6.C: New test.
* g++.dg/warn/Wwrite-strings-7.C: New test.
* g++.dg/warn/Wwrite-strings-8.C: New test.
* g++.dg/warn/Wwrite-strings-9.C: New test.
* g++.dg/warn/Wwrite-strings-10.C: New test.
* g++.dg/warn/Wwrite-strings-11.C: New test.
* g++.dg/warn/Wwrite-strings-12.C: New test.

From-SVN: r245864

15 files changed:
gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wwrite-strings-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wwrite-strings-10.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wwrite-strings-11.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wwrite-strings-12.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wwrite-strings-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wwrite-strings-3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wwrite-strings-4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wwrite-strings-5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wwrite-strings-6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wwrite-strings-7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wwrite-strings-8.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wwrite-strings-9.C [new file with mode: 0644]

index be98880c96389e18821c1b6fcc8b1ed1fd50624c..7ff2827e5025555001f4aeb693ead7c1654f2858 100644 (file)
@@ -1,3 +1,9 @@
+2017-03-03  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/79791
+       * typeck.c (string_conv_p): In C++11, always call pedwarn with
+       OPT_Wwrite_strings.
+
 2017-03-02  Jason Merrill  <jason@redhat.com>
 
        Update overload resolution with deduction guides.
index 3216bc41edf47b5173990a4a5596d37038554d7a..d1111248dc70ab7d08ccebc280f4c3f342f03d27 100644 (file)
@@ -2175,8 +2175,7 @@ string_conv_p (const_tree totype, const_tree exp, int warn)
   if (warn)
     {
       if (cxx_dialect >= cxx11)
-       pedwarn (input_location,
-                pedantic ? OPT_Wpedantic : OPT_Wwrite_strings,
+       pedwarn (input_location, OPT_Wwrite_strings,
                 "ISO C++ forbids converting a string constant to %qT",
                 totype);
       else
index e5a08ac0290b1c888e80ddb0be709459551f1c7f..502a0736b34c6d2419ae9fc1b09ea8d4ab7024bf 100644 (file)
@@ -1,3 +1,19 @@
+2017-03-03  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/79791
+       * g++.dg/warn/Wwrite-strings-1.C: New test.
+       * g++.dg/warn/Wwrite-strings-2.C: New test.
+       * g++.dg/warn/Wwrite-strings-3.C: New test.
+       * g++.dg/warn/Wwrite-strings-4.C: New test.
+       * g++.dg/warn/Wwrite-strings-5.C: New test.
+       * g++.dg/warn/Wwrite-strings-6.C: New test.
+       * g++.dg/warn/Wwrite-strings-7.C: New test.
+       * g++.dg/warn/Wwrite-strings-8.C: New test.
+       * g++.dg/warn/Wwrite-strings-9.C: New test.
+       * g++.dg/warn/Wwrite-strings-10.C: New test.
+       * g++.dg/warn/Wwrite-strings-11.C: New test.
+       * g++.dg/warn/Wwrite-strings-12.C: New test.
+
 2017-03-03  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/79818
diff --git a/gcc/testsuite/g++.dg/warn/Wwrite-strings-1.C b/gcc/testsuite/g++.dg/warn/Wwrite-strings-1.C
new file mode 100644 (file)
index 0000000..05abca3
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/79791
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+char *s = "foo"; // { dg-warning "ISO C\\+\\+ forbids converting a string constant" }
diff --git a/gcc/testsuite/g++.dg/warn/Wwrite-strings-10.C b/gcc/testsuite/g++.dg/warn/Wwrite-strings-10.C
new file mode 100644 (file)
index 0000000..d34b0b0
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/79791
+// { dg-do compile { target { ! c++11 } } }
+// { dg-options "" }
+
+char *s = "foo"; // { dg-warning "deprecated conversion from string constant" }
diff --git a/gcc/testsuite/g++.dg/warn/Wwrite-strings-11.C b/gcc/testsuite/g++.dg/warn/Wwrite-strings-11.C
new file mode 100644 (file)
index 0000000..11ddcdb
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/79791
+// { dg-do compile { target { ! c++11 } } }
+// { dg-options "-pedantic-errors" }
+
+char *s = "foo"; // { dg-warning "deprecated conversion from string constant" }
diff --git a/gcc/testsuite/g++.dg/warn/Wwrite-strings-12.C b/gcc/testsuite/g++.dg/warn/Wwrite-strings-12.C
new file mode 100644 (file)
index 0000000..754a9c8
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/79791
+// { dg-do compile { target { ! c++11 } } }
+// { dg-options "-Werror=write-strings" }
+// { dg-message "some warnings being treated as errors" "" { target *-*-* } 0 }
+
+char *s = "foo"; // { dg-error "deprecated conversion from string constant" }
diff --git a/gcc/testsuite/g++.dg/warn/Wwrite-strings-2.C b/gcc/testsuite/g++.dg/warn/Wwrite-strings-2.C
new file mode 100644 (file)
index 0000000..53084d9
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/79791
+// { dg-do compile { target c++11 } }
+// { dg-options "-pedantic-errors" }
+
+char *s = "foo"; // { dg-error "ISO C\\+\\+ forbids converting a string constant" }
diff --git a/gcc/testsuite/g++.dg/warn/Wwrite-strings-3.C b/gcc/testsuite/g++.dg/warn/Wwrite-strings-3.C
new file mode 100644 (file)
index 0000000..6cb9654
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/79791
+// { dg-do compile { target c++11 } }
+// { dg-options "-pedantic-errors -Wno-write-strings" }
+
+char *s = "foo";
diff --git a/gcc/testsuite/g++.dg/warn/Wwrite-strings-4.C b/gcc/testsuite/g++.dg/warn/Wwrite-strings-4.C
new file mode 100644 (file)
index 0000000..2654c39
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/79791
+// { dg-do compile { target c++11 } }
+// { dg-options "-Werror=write-strings" }
+// { dg-message "some warnings being treated as errors" "" { target *-*-* } 0 }
+
+char *s = "foo"; // { dg-error "ISO C\\+\\+ forbids converting a string constant" }
diff --git a/gcc/testsuite/g++.dg/warn/Wwrite-strings-5.C b/gcc/testsuite/g++.dg/warn/Wwrite-strings-5.C
new file mode 100644 (file)
index 0000000..f58ea90
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/79791
+// { dg-do compile { target c++11 } }
+// { dg-options "-Werror=write-strings -Wpedantic" }
+// { dg-message "some warnings being treated as errors" "" { target *-*-* } 0 }
+
+char *s = "foo"; // { dg-error "ISO C\\+\\+ forbids converting a string constant" }
diff --git a/gcc/testsuite/g++.dg/warn/Wwrite-strings-6.C b/gcc/testsuite/g++.dg/warn/Wwrite-strings-6.C
new file mode 100644 (file)
index 0000000..ff89f38
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/79791
+// { dg-do compile { target c++11 } }
+// { dg-options "-Werror=write-strings -Wno-pedantic" }
+// { dg-message "some warnings being treated as errors" "" { target *-*-* } 0 }
+
+char *s = "foo"; // { dg-error "ISO C\\+\\+ forbids converting a string constant" }
diff --git a/gcc/testsuite/g++.dg/warn/Wwrite-strings-7.C b/gcc/testsuite/g++.dg/warn/Wwrite-strings-7.C
new file mode 100644 (file)
index 0000000..13a8291
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/79791
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wno-write-strings" }
+
+char *s = "foo";
diff --git a/gcc/testsuite/g++.dg/warn/Wwrite-strings-8.C b/gcc/testsuite/g++.dg/warn/Wwrite-strings-8.C
new file mode 100644 (file)
index 0000000..df5f283
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/79791
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wpedantic -Wno-write-strings" }
+
+char *s = "foo";
diff --git a/gcc/testsuite/g++.dg/warn/Wwrite-strings-9.C b/gcc/testsuite/g++.dg/warn/Wwrite-strings-9.C
new file mode 100644 (file)
index 0000000..5db813b
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/79791
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wno-error=write-strings -pedantic-errors" }
+
+char *s = "foo"; // { dg-warning "ISO C\\+\\+ forbids converting a string constant" }