Message ID | CAFk2RUY6V1C-O1mUj93Wkda9_zs_GXn-i6oWXiEO91x-9QxqJw@mail.gmail.com |
---|---|
State | New |
Headers | show |
Tested how, exactly? It doesn't seem to have run old-deja.exp. I tend to use the toplevel make-c++ target. > +FAIL: g++.old-deja/g++.bob/inherit1.C -std=c++11 depr (test for warnings, line 14) > +FAIL: g++.old-deja/g++.bob/inherit1.C -std=c++11 (test for excess errors) > +FAIL: g++.old-deja/g++.bob/inherit1.C -std=c++14 depr (test for warnings, line 14) > +FAIL: g++.old-deja/g++.bob/inherit1.C -std=c++14 (test for excess errors) > +FAIL: g++.old-deja/g++.brendan/template17.C -std=c++11 depr (test for warnings, line 11) > +FAIL: g++.old-deja/g++.brendan/template17.C -std=c++11 (test for excess errors) > +FAIL: g++.old-deja/g++.brendan/template17.C -std=c++14 depr (test for warnings, line 11) > +FAIL: g++.old-deja/g++.brendan/template17.C -std=c++14 (test for excess errors) > +FAIL: g++.old-deja/g++.law/temps1.C -std=gnu++11 dep (test for warnings, line 19) > +FAIL: g++.old-deja/g++.law/temps1.C -std=gnu++11 (test for excess errors) > +FAIL: g++.old-deja/g++.law/temps1.C -std=gnu++14 dep (test for warnings, line 19) > +FAIL: g++.old-deja/g++.law/temps1.C -std=gnu++14 (test for excess errors) > +FAIL: g++.old-deja/g++.martin/typedef2.C -std=c++11 (test for excess errors) > +FAIL: g++.old-deja/g++.martin/typedef2.C -std=c++11 (test for warnings, line 6) > +FAIL: g++.old-deja/g++.martin/typedef2.C -std=c++14 (test for excess errors) > +FAIL: g++.old-deja/g++.martin/typedef2.C -std=c++14 (test for warnings, line 6) Jason
On 11/25/2014 09:41 PM, Jason Merrill wrote: > Tested how, exactly? It doesn't seem to have run old-deja.exp. I tend > to use the toplevel make-c++ target. Er, check-c++. Jason
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 7156851..c7d422a 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -2139,12 +2139,24 @@ 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 (warn) { + if (cxx_dialect >= cxx11) + { + if (pedantic) + pedwarn (input_location, OPT_Wpedantic, + "ISO C++ forbids converting a string constant to %qT", + totype); + else + warning (OPT_Wwrite_strings, + "ISO C++ forbids converting a string constant to %qT", + totype); + } + /* This warning is not very useful, as it complains about printf. */ + else + warning (OPT_Wwrite_strings, + "deprecated conversion from string constant to %qT", + totype); + } return 1; } diff --git a/gcc/testsuite/g++.dg/warn/write-strings-default.C b/gcc/testsuite/g++.dg/warn/write-strings-default.C index ee6b217..063b303 100644 --- a/gcc/testsuite/g++.dg/warn/write-strings-default.C +++ b/gcc/testsuite/g++.dg/warn/write-strings-default.C @@ -3,5 +3,5 @@ int main() { - char* p = "Asgaard"; // { dg-warning "deprecated" } + char* p = "Asgaard"; // { dg-warning "deprecated|forbids converting a string constant" } } diff --git a/gcc/testsuite/g++.dg/warn/write-strings.C b/gcc/testsuite/g++.dg/warn/write-strings.C index 73c8149..1293e85 100644 --- a/gcc/testsuite/g++.dg/warn/write-strings.C +++ b/gcc/testsuite/g++.dg/warn/write-strings.C @@ -3,5 +3,5 @@ int main() { - char* p = "Asgaard"; // { dg-warning "deprecated" } + char* p = "Asgaard"; // { dg-warning "deprecated|forbids converting a string constant" } }