Sorry to be pedantic, but I think this is not exactly right:

+    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);
+      }

Quoting from here: https://gcc.gnu.org/wiki/DiagnosticsGuidelines

pedwarn is for code that is accepted by GCC but it should be rejected
or diagnosed according to the current standard, or it conflicts with
the standard (either the default or the one selected by -std=). Most
pedwarns are controlled by -Wpedantic, a few are controlled by options
that are enabled by -Wpedantic and others are enabled by default.

That is, although Wpedantic is only used for pedwarns, the distinction
between pedwarn and warning is independent of Wpedantic and only
depends on the current -std= value.

If I understand correctly, the cxx11 standard requires to diagnose
this. Thus, it should be always a pedwarn, independently of Wpedantic.
Now, if we also want to warn for Wwrite_strings, then you can do:

+    if (cxx_dialect >= cxx11)
+      {
+  pedwarn (input_location, pedantic ? OPT_Wpedantic : OPT_Wwrite_strings,
+   "ISO C++ forbids converting a string constant to %qT",
+   totype);
+      }

The effect is the same, because right now there is no difference
between pedwarn and warning except when -pedantic-errors is given, and
that will enable Wpedantic anyway. However, since the latter code is
simpler and pedantically more correct, I'd suggest to use that.

Cheers,

Manuel.

Reply via email to