summaryrefslogtreecommitdiff
path: root/gcc/cp/typeck.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2014-11-26 15:16:07 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2014-11-26 15:16:07 +0000
commit2aeccf739475ee181f4ca6422776b46bc9526352 (patch)
tree1d0719c39e7bc778963f5959e441ce9f55e4c8b9 /gcc/cp/typeck.c
parent6d31c916e0682010ba9a3d2c1c7647201c28883c (diff)
downloadgcc-2aeccf739475ee181f4ca6422776b46bc9526352.tar.gz
Diagnose string constant conversion to char* in c++11 and above
as forbidden, not deprecated. * typeck.c (string_conv_p): Do a pedwarn in c++11 and above, change the diagnostic for the Wwrite-strings case for c++11 and above. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@218087 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/typeck.c')
-rw-r--r--gcc/cp/typeck.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index e100d70b1f2..8b66acc9011 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -2139,12 +2139,18 @@ string_conv_p (const_tree totype, const_tree exp, int warn)
|| TREE_CODE (TREE_OPERAND (exp, 0)) != STRING_CST)
return 0;
}
-
- /* This warning is not very useful, as it complains about printf. */
if (warn)
- warning (OPT_Wwrite_strings,
- "deprecated conversion from string constant to %qT",
- totype);
+ {
+ if (cxx_dialect >= cxx11)
+ pedwarn (input_location,
+ pedantic ? OPT_Wpedantic : OPT_Wwrite_strings,
+ "ISO C++ forbids converting a string constant to %qT",
+ totype);
+ else
+ warning (OPT_Wwrite_strings,
+ "deprecated conversion from string constant to %qT",
+ totype);
+ }
return 1;
}