aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorJoseph Myers <jsm28@cam.ac.uk>2000-12-01 22:43:33 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2000-12-01 22:43:33 +0000
commit4d80892796677b2beaf9d47d80e337b315395582 (patch)
treebdb5953541ec233f2de9b035d07dd0cc7f8757c2 /gcc/c-decl.c
parente78f4a977a1f0f802035fd473d64659d4f48a8ab (diff)
downloadgcc-4d80892796677b2beaf9d47d80e337b315395582.zip
gcc-4d80892796677b2beaf9d47d80e337b315395582.tar.gz
gcc-4d80892796677b2beaf9d47d80e337b315395582.tar.bz2
c-common.c (warn_format, [...]): Define.
* c-common.c (warn_format, warn_format_y2k, warn_format_extra_args, warn_format_nonliteral): Define. (check_format_info): Check warn_format_nonliteral and warn_format_extra_args. (check_format_info_main): Check warn_format_y2k. (set_Wformat): New function. * c-common.h (warn_format_y2k, warn_format_extra_args, warn_format_nonliteral, set_Wformat): Declare. * c-decl.c (warn_format): Remove definition. (c_decode_option): Handle -Wformat-nonliteral, -Wno-format-extra-args and -Wno-format-y2k, and negated versions. Use set_Wformat. * invoke.texi: Document these new options and -Wformat=2. * toplev.c (documented_lang_options): Add these new options. cp: * decl2.c (warn_format): Remove definition. (lang_decode_option): Handle -Wformat-nonliteral, -Wno-format-extra-args and -Wno-format-y2k. Use set_Wformat. testsuite: * gcc.dg/format-no-exargs-1.c, gcc.dg/format-no-y2k-1.c, gcc.dg/format-nonlit-1.c, gcc.dg/format-nonlit-2.c: New tests. From-SVN: r37933
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index e7c5988..1c1f138 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -421,10 +421,6 @@ int warn_redundant_decls = 0;
int warn_nested_externs = 0;
-/* Warn about *printf or *scanf format/argument anomalies. */
-
-int warn_format;
-
/* Warn about a subscript that has type char. */
int warn_char_subscripts = 0;
@@ -710,11 +706,23 @@ c_decode_option (argc, argv)
else if (!strcmp (p, "-Wno-traditional"))
warn_traditional = 0;
else if (!strncmp (p, "-Wformat=", 9))
- warn_format = atol (p + 9);
+ set_Wformat (atoi (p + 9));
else if (!strcmp (p, "-Wformat"))
- warn_format = 1;
+ set_Wformat (1);
else if (!strcmp (p, "-Wno-format"))
- warn_format = 0;
+ set_Wformat (0);
+ else if (!strcmp (p, "-Wformat-y2k"))
+ warn_format_y2k = 1;
+ else if (!strcmp (p, "-Wno-format-y2k"))
+ warn_format_y2k = 0;
+ else if (!strcmp (p, "-Wformat-extra-args"))
+ warn_format_extra_args = 1;
+ else if (!strcmp (p, "-Wno-format-extra-args"))
+ warn_format_extra_args = 0;
+ else if (!strcmp (p, "-Wformat-nonliteral"))
+ warn_format_nonliteral = 1;
+ else if (!strcmp (p, "-Wno-format-nonliteral"))
+ warn_format_nonliteral = 0;
else if (!strcmp (p, "-Wchar-subscripts"))
warn_char_subscripts = 1;
else if (!strcmp (p, "-Wno-char-subscripts"))
@@ -793,7 +801,7 @@ c_decode_option (argc, argv)
warn_return_type = 1;
set_Wunused (1);
warn_switch = 1;
- warn_format = 1;
+ set_Wformat (1);
warn_char_subscripts = 1;
warn_parentheses = 1;
warn_sequence_point = 1;