re PR c++/79791 (-Werror=write-strings ignored with -Wpedantic)

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
This commit is contained in:
Marek Polacek 2017-03-03 09:58:10 +00:00 committed by Marek Polacek
parent 5719c938be
commit 7278b0a266
15 changed files with 87 additions and 2 deletions

View 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.

View 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

View 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

View File

@ -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" }

View File

@ -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" }

View File

@ -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" }

View File

@ -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" }

View File

@ -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" }

View File

@ -0,0 +1,5 @@
// PR c++/79791
// { dg-do compile { target c++11 } }
// { dg-options "-pedantic-errors -Wno-write-strings" }
char *s = "foo";

View File

@ -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" }

View File

@ -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" }

View File

@ -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" }

View File

@ -0,0 +1,5 @@
// PR c++/79791
// { dg-do compile { target c++11 } }
// { dg-options "-Wno-write-strings" }
char *s = "foo";

View File

@ -0,0 +1,5 @@
// PR c++/79791
// { dg-do compile { target c++11 } }
// { dg-options "-Wpedantic -Wno-write-strings" }
char *s = "foo";

View File

@ -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" }