This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch to warn for format warning options with no effect
- To: <gcc-patches at gcc dot gnu dot org>
- Subject: Patch to warn for format warning options with no effect
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Thu, 7 Dec 2000 13:10:20 +0000 (GMT)
This patch makes GCC warn if options such as
-Wmissing-format-attribute and -Wformat-nonliteral get used without
-Wformat (in which case they do nothing useful).
Bootstrapped with no regressions on i686-pc-linux-gnu. OK to commit?
2000-12-07 Joseph S. Myers <jsm28@cam.ac.uk>
* c-common.c (c_common_lang_init): New function. Warn if format
warning options which only have effects when used with -Wformat
are used without -Wformat.
* c-common.h (c_common_lang_init): Declare.
* c-lang.c (lang_init): Call c_common_lang_init.
2000-12-07 Joseph S. Myers <jsm28@cam.ac.uk>
* lex.c (lang_init): Call c_common_lang_init.
--- c-common.c.orig Wed Dec 6 22:19:27 2000
+++ c-common.c Wed Dec 6 22:44:47 2000
@@ -6452,3 +6452,26 @@ boolean_increment (code, arg)
TREE_SIDE_EFFECTS (val) = 1;
return val;
}
+
+
+/* Do the parts of lang_init common to C and C++. */
+void
+c_common_lang_init ()
+{
+ /* If still "unspecified", make it match -fbounded-pointers. */
+ if (flag_bounds_check < 0)
+ flag_bounds_check = flag_bounded_pointers;
+
+ /* Special format checking options don't work without -Wformat; warn if
+ they are used. */
+ if (warn_format_y2k && !warn_format)
+ warning ("-Wformat-y2k ignored without -Wformat");
+ if (warn_format_extra_args && !warn_format)
+ warning ("-Wformat-extra-args ignored without -Wformat");
+ if (warn_format_nonliteral && !warn_format)
+ warning ("-Wformat-nonliteral ignored without -Wformat");
+ if (warn_format_security && !warn_format)
+ warning ("-Wformat-security ignored without -Wformat");
+ if (warn_missing_format_attribute && !warn_format)
+ warning ("-Wmissing-format-attribute ignored without -Wformat");
+}
--- c-common.h.orig Wed Dec 6 22:19:28 2000
+++ c-common.h Wed Dec 6 22:39:28 2000
@@ -502,6 +502,8 @@ extern void c_common_nodes_and_builtins
extern tree build_va_arg PARAMS ((tree, tree));
+extern void c_common_lang_init PARAMS ((void));
+
/* Nonzero if the type T promotes to itself.
ANSI C states explicitly the list of types that promote;
in particular, short promotes to int even if they have the same width. */
--- c-lang.c.orig Wed Nov 29 00:33:05 2000
+++ c-lang.c Wed Dec 6 22:41:22 2000
@@ -61,9 +61,7 @@ lang_init_options ()
void
lang_init ()
{
- /* If still "unspecified", make it match -fbounded-pointers. */
- if (flag_bounds_check < 0)
- flag_bounds_check = flag_bounded_pointers;
+ c_common_lang_init ();
/* If still unspecified, make it match pedantic && -std=c99. */
if (mesg_implicit_function_declaration < 0)
--- cp/lex.c.orig Wed Nov 29 00:33:15 2000
+++ cp/lex.c Wed Dec 6 22:41:39 2000
@@ -262,9 +262,7 @@ lang_init_options ()
void
lang_init ()
{
- /* If still "unspecified", make it match -fbounded-pointers. */
- if (flag_bounds_check < 0)
- flag_bounds_check = flag_bounded_pointers;
+ c_common_lang_init ();
if (flag_gnu_xref) GNU_xref_begin (input_filename);
init_repo (input_filename);
--
Joseph S. Myers
jsm28@cam.ac.uk