Commit 7278b0a2 by Marek Polacek Committed by Marek Polacek

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
parent 5719c938
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.
......
......@@ -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
......
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
......
// PR c++/79791
// { dg-do compile { target c++11 } }
// { dg-options "" }
char *s = "foo"; // { dg-warning "ISO C\\+\\+ forbids converting a string constant" }
// PR c++/79791
// { dg-do compile { target { ! c++11 } } }
// { dg-options "" }
char *s = "foo"; // { dg-warning "deprecated conversion from string constant" }
// PR c++/79791
// { dg-do compile { target { ! c++11 } } }
// { dg-options "-pedantic-errors" }
char *s = "foo"; // { dg-warning "deprecated conversion from string constant" }
// 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" }
// 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" }
// PR c++/79791
// { dg-do compile { target c++11 } }
// { dg-options "-pedantic-errors -Wno-write-strings" }
char *s = "foo";
// 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" }
// 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" }
// 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" }
// PR c++/79791
// { dg-do compile { target c++11 } }
// { dg-options "-Wno-write-strings" }
char *s = "foo";
// PR c++/79791
// { dg-do compile { target c++11 } }
// { dg-options "-Wpedantic -Wno-write-strings" }
char *s = "foo";
// 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" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment