On 26 November 2014 at 04:42, Jason Merrill <ja...@redhat.com> wrote:
> 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

Too hastily, sorry. I managed to notice that the tests adjusted in the patch
failed, and then blissfully didn't look at the further tests.

>> to use the toplevel make-c++ target.
>
>
> Er, check-c++.


Yeah, I ran check-gcc-c++, but conveniently didn't look at the results
thoroughly
enough. New patch attached, tested until the very end including old-deja,
no regressions anymore.

/cp
2014-11-26  Ville Voutilainen  <ville.voutilai...@gmail.com>

    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.

/testsuite
2014-11-26  Ville Voutilainen  <ville.voutilai...@gmail.com>

    Diagnose string constant conversion to char* in c++11 and above
    as forbidden, not deprecated.
    * g++.dg/warn/write-strings-default.C: Adjust.
    * g++.dg/warn/write-strings.C: Likewise.
    * g++.old-deja/g++.bob/inherit1.C: Likewise.
    * g++.old-deja/g++.brendan/template17.C: Likewise.
    * g++.old-deja/g++.law/temps1.C: Likewise.
    * g++.old-deja/g++.martin/typedef2.C: Likewise.
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" }
 }
diff --git a/gcc/testsuite/g++.old-deja/g++.bob/inherit1.C 
b/gcc/testsuite/g++.old-deja/g++.bob/inherit1.C
index e75190b..c037a1c 100644
--- a/gcc/testsuite/g++.old-deja/g++.bob/inherit1.C
+++ b/gcc/testsuite/g++.old-deja/g++.bob/inherit1.C
@@ -12,7 +12,7 @@ public:
 class B : public A {
 public:
     char* m1 () { C::m1(); return ""; } // { dg-error "cannot call" } 
-    // { dg-warning "deprecated" "depr" { target *-*-* } 14 }
+    // { dg-warning "deprecated|forbids converting a string constant" "depr" { 
target *-*-* } 14 }
 };
 
 int main () {
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template17.C 
b/gcc/testsuite/g++.old-deja/g++.brendan/template17.C
index 94eaf3d..b8e2a0b 100644
--- a/gcc/testsuite/g++.old-deja/g++.brendan/template17.C
+++ b/gcc/testsuite/g++.old-deja/g++.brendan/template17.C
@@ -10,6 +10,6 @@ public:
 
 const Regex NDAMName<'L'>::pattern("^[Ll](.*)$",   1);// { dg-error 
"type/value mismatch" "mismatch" }
 // { dg-message "expected a type" "expected" { target *-*-* } 11 }
-// { dg-warning "deprecated" "depr" { target *-*-* } 11 }
+// { dg-warning "deprecated|forbids converting a string constant" "depr" { 
target *-*-* } 11 }
 unsigned NDAMName<'L'>::sequence_number = 0;// { dg-error "type/value 
mismatch" "mismatch" }
 // { dg-message "expected a type" "exp" { target *-*-* } 14 }
diff --git a/gcc/testsuite/g++.old-deja/g++.law/temps1.C 
b/gcc/testsuite/g++.old-deja/g++.law/temps1.C
index bd344b4..5734210 100644
--- a/gcc/testsuite/g++.old-deja/g++.law/temps1.C
+++ b/gcc/testsuite/g++.old-deja/g++.law/temps1.C
@@ -16,5 +16,5 @@ struct cookie
   cookie ( foo * x) { v=x; }
 };
 
-cookie cat(&foo("apabepa"));// { dg-warning "deprecated conversion" "dep" }
+cookie cat(&foo("apabepa"));// { dg-warning "deprecated conversion|forbids 
converting a string constant" "dep" }
 // { dg-warning "taking address of temporary" "add" { target *-*-* } 19 }
diff --git a/gcc/testsuite/g++.old-deja/g++.martin/typedef2.C 
b/gcc/testsuite/g++.old-deja/g++.martin/typedef2.C
index fa31867..99603cf 100644
--- a/gcc/testsuite/g++.old-deja/g++.martin/typedef2.C
+++ b/gcc/testsuite/g++.old-deja/g++.martin/typedef2.C
@@ -3,5 +3,5 @@
 // Check implicit conversion from string constants into typedefs
 
 typedef char CHAR;
-void f2(CHAR *s="");           // { dg-warning "deprecated" }
+void f2(CHAR *s="");           // { dg-warning "deprecated|forbids converting 
a string constant" }
 

Reply via email to