Hi,
in this simple PR, submitter remarks that there isn't a real reason not
to have -W(no-)format-zero-length working in C++ exactly like in C.
In fact, the status quo is that the warning *is* active in C++ too, part
of -Wformat, but it cannot be *disabled*, because
-Wno-format-zero-length is not a legal C++ option!
Thus the below, tested x86_64-linux. Ok for mainline?
Thanks,
Paolo.
////////////////////////
/gcc
2011-10-13 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/17212
* c-family/c.opt ([Wformat-zero-length]): Add C++.
* doc/invoke.texi: Update.
/testsuite
2011-10-13 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/17212
* g++.dg/warn/format6.C: New.
Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi (revision 179904)
+++ doc/invoke.texi (working copy)
@@ -3189,7 +3189,7 @@ in the case of @code{scanf} formats, this option w
warning if the unused arguments are all pointers, since the Single
Unix Specification says that such unused arguments are allowed.
-@item -Wno-format-zero-length @r{(C and Objective-C only)}
+@item -Wno-format-zero-length @r{(C, C++ and Objective-C)}
@opindex Wno-format-zero-length
@opindex Wformat-zero-length
If @option{-Wformat} is specified, do not warn about zero-length formats.
Index: c-family/c.opt
===================================================================
--- c-family/c.opt (revision 179904)
+++ c-family/c.opt (working copy)
@@ -396,7 +396,7 @@ C ObjC C++ ObjC++ Var(warn_format_y2k) Warning
Warn about strftime formats yielding 2-digit years
Wformat-zero-length
-C ObjC Var(warn_format_zero_length) Warning
+C ObjC C++ Var(warn_format_zero_length) Warning
Warn about zero-length formats
Wformat=
Index: testsuite/g++.dg/warn/format6.C
===================================================================
--- testsuite/g++.dg/warn/format6.C (revision 0)
+++ testsuite/g++.dg/warn/format6.C (revision 0)
@@ -0,0 +1,7 @@
+// PR c++/17212
+// { dg-options "-Wformat -Wno-format-zero-length" }
+
+void f()
+{
+ __builtin_printf("");
+}