public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PR c/53063 Handle Wformat with LangEnabledBy
@ 2012-10-17 22:24 Manuel López-Ibáñez
  2012-10-19 16:22 ` Joseph S. Myers
  0 siblings, 1 reply; 6+ messages in thread
From: Manuel López-Ibáñez @ 2012-10-17 22:24 UTC (permalink / raw)
  To: Gcc Patch List

[-- Attachment #1: Type: text/plain, Size: 1288 bytes --]

Bootstrapped and regression tested on x86_64-linux-gnu. Since Wformat
didn't have Var() associated, its corresponding entry was set to -1,
which is what warning(OPT_Wformat) checks for. Therefore, any such
warnings which were not guarded by if(warn_format), were enabled by
default. I only found one case in the objective-C FE.

The old code accepts -Wformat=X with X any number but -Wno-format=2
does not have any effect. The documentation only mentions -Wformat,
-Wno-format, -Wformat=2 and -Wno-format=2. I followed the
documentation but I can also implement -Wformat=0 being an alias for
-Wno-format and -Wformat=1 an alias for -Wformat and simply reject
-Wno-format=.

2012-10-17  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c/53063
c-family/
	* c.opt (Wformat, Wformat-extra-args, Wformat-nonliteral,
	Wformat-contains-nul, Wformat-security, Wformat-y2k,
	Wformat-zero-length, Wformat=2, Wnonnull): Use LangEnabledBy.
	* c-opts.c (c_common_handle_option): Do not handle explicitly
	here.
	* c-common.c (warn_format): Delete.
	* c-format.c (set_Wformat): Delete.
	* c-common.h (warn_format,set_Wformat): Do not declare.
testsuite/
	* gcc.dg/warn-nsstring.c: Add -Wformat.
	* gcc.misc-tests/help.exp (check_for_options): Use
	-Wstrict-aliasing for test.

[-- Attachment #2: wformat.diff --]
[-- Type: application/octet-stream, Size: 8915 bytes --]

Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt	(revision 192504)
+++ gcc/c-family/c.opt	(working copy)
@@ -371,39 +371,43 @@ This switch is deprecated; use -Werror=i
 Wfloat-equal
 C ObjC C++ ObjC++ Var(warn_float_equal) Warning
 Warn if testing floating point numbers for equality
 
 Wformat
-C ObjC C++ ObjC++ Warning
+C ObjC C++ ObjC++ Var(warn_format) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=2,2,0)
 Warn about printf/scanf/strftime/strfmon format string anomalies
 
+Wformat
+C ObjC C++ ObjC++ LangEnabledBy(C ObjC C++ ObjC++,Wall)
+;
+
 Wformat-extra-args
-C ObjC C++ ObjC++ Var(warn_format_extra_args) Warning
+C ObjC C++ ObjC++ Var(warn_format_extra_args) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat)
 Warn if passing too many arguments to a function for its format string
 
 Wformat-nonliteral
-C ObjC C++ ObjC++ Var(warn_format_nonliteral) Warning
+C ObjC C++ ObjC++ Var(warn_format_nonliteral) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=2)
 Warn about format strings that are not literals
 
 Wformat-contains-nul
-C ObjC C++ ObjC++ Var(warn_format_contains_nul) Warning
+C ObjC C++ ObjC++ Var(warn_format_contains_nul) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat)
 Warn about format strings that contain NUL bytes
 
 Wformat-security
-C ObjC C++ ObjC++ Var(warn_format_security) Warning
+C ObjC C++ ObjC++ Var(warn_format_security) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=2)
 Warn about possible security problems with format functions
 
 Wformat-y2k
-C ObjC C++ ObjC++ Var(warn_format_y2k) Warning
+C ObjC C++ ObjC++ Var(warn_format_y2k) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=2)
 Warn about strftime formats yielding 2-digit years
 
 Wformat-zero-length
-C ObjC C++ ObjC++ Var(warn_format_zero_length) Warning
+C ObjC C++ ObjC++ Var(warn_format_zero_length) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat)
 Warn about zero-length formats
 
-Wformat=
-C ObjC C++ ObjC++ Joined Warning
+Wformat=2
+C ObjC C++ ObjC++ Warning
 
 Wignored-qualifiers
 C C++ Var(warn_ignored_qualifiers) Warning EnabledBy(Wextra)
 Warn whenever type qualifiers are ignored.
 
@@ -524,13 +528,17 @@ Warn when non-templatized friend functio
 Wnon-virtual-dtor
 C++ ObjC++ Var(warn_nonvdtor) Warning
 Warn about non-virtual destructors
 
 Wnonnull
-C ObjC C++ ObjC++ Var(warn_nonnull) Warning
+C ObjC C++ ObjC++ Var(warn_nonnull) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat)
 Warn about NULL being passed to argument slots marked as requiring non-NULL
 
+Wnonnull
+C ObjC C++ ObjC++ LangEnabledBy(C ObjC C++ ObjC++,Wall)
+;
+
 Wnormalized=
 C ObjC C++ ObjC++ Joined Warning
 -Wnormalized=<id|nfc|nfkc>	Warn about non-normalised Unicode strings
 
 Wold-style-cast
Index: gcc/c-family/c-opts.c
===================================================================
--- gcc/c-family/c-opts.c	(revision 192504)
+++ gcc/c-family/c-opts.c	(working copy)
@@ -363,11 +363,10 @@ c_common_handle_option (size_t scode, co
       /* ??? Don't add new options here. Use LangEnabledBy in c.opt.  */
       handle_generated_option (&global_options, &global_options_set,
 			       OPT_Wunused, NULL, value,
 			       c_family_lang_mask, kind, loc,
 			       handlers, global_dc);
-      set_Wformat (value);
       handle_generated_option (&global_options, &global_options_set,
 			       OPT_Wimplicit, NULL, value,
 			       c_family_lang_mask, kind, loc,
 			       handlers, global_dc);
       warn_char_subscripts = value;
@@ -441,18 +440,10 @@ c_common_handle_option (size_t scode, co
 
     case OPT_Wendif_labels:
       cpp_opts->warn_endif_labels = value;
       break;
 
-    case OPT_Wformat:
-      set_Wformat (value);
-      break;
-
-    case OPT_Wformat_:
-      set_Wformat (atoi (arg));
-      break;
-
     case OPT_Wimplicit:
       gcc_assert (value == 0 || value == 1);
       if (warn_implicit_int == -1)
 	handle_generated_option (&global_options, &global_options_set,
 				 OPT_Wimplicit_int, NULL, value,
Index: gcc/c-family/c-common.c
===================================================================
--- gcc/c-family/c-common.c	(revision 192504)
+++ gcc/c-family/c-common.c	(working copy)
@@ -195,15 +195,10 @@ int flag_iso;
 
 /* Warn about #pragma directives that are not recognized.  */
 
 int warn_unknown_pragmas; /* Tri state variable.  */
 
-/* Warn about format/argument anomalies in calls to formatted I/O functions
-   (*printf, *scanf, strftime, strfmon, etc.).  */
-
-int warn_format;
-
 /* C/ObjC language option variables.  */
 
 
 /* Nonzero means allow type mismatches in conditional expressions;
    just make their values `void'.  */
Index: gcc/c-family/c-format.c
===================================================================
--- gcc/c-family/c-format.c	(revision 192504)
+++ gcc/c-family/c-format.c	(working copy)
@@ -32,31 +32,10 @@ along with GCC; see the file COPYING3.  
 #include "langhooks.h"
 #include "c-format.h"
 #include "alloc-pool.h"
 #include "c-target.h"
 \f
-/* Set format warning options according to a -Wformat=n option.  */
-
-void
-set_Wformat (int setting)
-{
-  warn_format = setting;
-  warn_format_extra_args = setting;
-  warn_format_zero_length = setting;
-  warn_format_contains_nul = setting;
-  if (setting != 1)
-    {
-      warn_format_nonliteral = setting;
-      warn_format_security = setting;
-      warn_format_y2k = setting;
-    }
-  /* Make sure not to disable -Wnonnull if -Wformat=0 is specified.  */
-  if (setting)
-    warn_nonnull = setting;
-}
-
-\f
 /* Handle attributes associated with format checking.  */
 
 /* This must be in the same order as format_types, except for
    format_type_error.  Target-specific format types do not have
    matching enum values.  */
Index: gcc/c-family/c-common.h
===================================================================
--- gcc/c-family/c-common.h	(revision 192504)
+++ gcc/c-family/c-common.h	(working copy)
@@ -587,16 +587,10 @@ extern int flag_iso;
 
 /* Warn about #pragma directives that are not recognized.  */
 
 extern int warn_unknown_pragmas; /* Tri state variable.  */
 
-/* Warn about format/argument anomalies in calls to formatted I/O functions
-   (*printf, *scanf, strftime, strfmon, etc.).  */
-
-extern int warn_format;
-
-
 /* C/ObjC language option variables.  */
 
 
 /* Nonzero means allow type mismatches in conditional expressions;
    just make their values `void'.  */
@@ -734,11 +728,10 @@ extern void check_function_arguments_rec
 					       unsigned HOST_WIDE_INT),
 					      void *, tree,
 					      unsigned HOST_WIDE_INT);
 extern bool check_builtin_function_arguments (tree, int, tree *);
 extern void check_function_format (tree, int, tree *);
-extern void set_Wformat (int);
 extern tree handle_format_attribute (tree *, tree, tree, int, bool *);
 extern tree handle_format_arg_attribute (tree *, tree, tree, int, bool *);
 extern bool attribute_takes_identifier_p (const_tree);
 extern bool c_common_handle_option (size_t, const char *, int, int, location_t,
 				    const struct cl_option_handlers *);
Index: gcc/testsuite/gcc.dg/warn-nsstring.c
===================================================================
--- gcc/testsuite/gcc.dg/warn-nsstring.c	(revision 192504)
+++ gcc/testsuite/gcc.dg/warn-nsstring.c	(working copy)
@@ -1,7 +1,7 @@
 /* Check that the NSString format extension is rejected in c.  */
 /* { dg-do compile } */
-
+/* { dg-options "-Wformat" } */
 extern void NSLog (void *fmt, ...) __attribute__((format(__NSString__, 1, 2))); /* { dg-warning "is only allowed in Objective-C dialects" } */
 extern void NSLog1 (void *fmt, ...) __attribute__((format(NSString, 1, 2))); /* { dg-warning "is only allowed in Objective-C dialects" } */
 
 
Index: gcc/testsuite/gcc.misc-tests/help.exp
===================================================================
--- gcc/testsuite/gcc.misc-tests/help.exp	(revision 192504)
+++ gcc/testsuite/gcc.misc-tests/help.exp	(working copy)
@@ -66,14 +66,14 @@ check_for_options c "--help=params --hel
 maximum number of
 -O
 } "" ""
 
 # Ensure PR 37805 is fixed.
-check_for_options c "--help=joined" "Wformat=" "-fstrict-prototype" ""
+check_for_options c "--help=joined" "Wstrict-aliasing=" "-fstrict-prototype" ""
 check_for_options c "--help=separate" "-MF" "-fstrict-prototype" ""
-check_for_options c "--help=warnings,joined" "Wformat=" "Wtrigraphs" ""
-check_for_options c "--help=warnings,^joined" "Wtrigraphs" "Wformat=" ""
+check_for_options c "--help=warnings,joined" "Wstrict-aliasing=" "Wtrigraphs" ""
+check_for_options c "--help=warnings,^joined" "Wtrigraphs" "Wstrict-aliasing=" ""
 check_for_options c "--help=joined,separate" "-I" "" ""
 check_for_options c "--help=^joined,separate" "--param " "" ""
 check_for_options c "--help=joined,^separate" "--help=" "" ""
 check_for_options c "--help=joined,undocumented" "" "" ""
 # Listing only excludes gives empty results.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PR c/53063 Handle Wformat with LangEnabledBy
  2012-10-17 22:24 PR c/53063 Handle Wformat with LangEnabledBy Manuel López-Ibáñez
@ 2012-10-19 16:22 ` Joseph S. Myers
  2012-10-23 19:38   ` Manuel López-Ibáñez
  2012-10-27 17:03   ` Manuel López-Ibáñez
  0 siblings, 2 replies; 6+ messages in thread
From: Joseph S. Myers @ 2012-10-19 16:22 UTC (permalink / raw)
  To: Manuel López-Ibáñez; +Cc: Gcc Patch List

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="X-UNKNOWN", Size: 485 bytes --]

On Wed, 17 Oct 2012, Manuel López-Ibáñez wrote:

> documentation but I can also implement -Wformat=0 being an alias for
> -Wno-format and -Wformat=1 an alias for -Wformat and simply reject
> -Wno-format=.

I think that's what's wanted; -Wno-format= should be rejected, -Wformat= 
should take an arbitrary integer level (of which at present all those 
above 2 are equivalent to 2, just as -O<n> for n > 3 is equivalent to 
-O3).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PR c/53063 Handle Wformat with LangEnabledBy
  2012-10-19 16:22 ` Joseph S. Myers
@ 2012-10-23 19:38   ` Manuel López-Ibáñez
  2012-10-24  0:54     ` Joseph S. Myers
  2012-10-27 17:03   ` Manuel López-Ibáñez
  1 sibling, 1 reply; 6+ messages in thread
From: Manuel López-Ibáñez @ 2012-10-23 19:38 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Gcc Patch List

On 19 October 2012 18:17, Joseph S. Myers <joseph@codesourcery.com> wrote:
> On Wed, 17 Oct 2012, Manuel López-Ibáñez wrote:
>
>> documentation but I can also implement -Wformat=0 being an alias for
>> -Wno-format and -Wformat=1 an alias for -Wformat and simply reject
>> -Wno-format=.
>
> I think that's what's wanted; -Wno-format= should be rejected, -Wformat=
> should take an arbitrary integer level (of which at present all those
> above 2 are equivalent to 2, just as -O<n> for n > 3 is equivalent to
> -O3).

The problem is how to represent that Wformat-y2k is enabled by
-Wformat=X with X >= 2, while Wformat-zero-length is enabled by X >=1.

One possiblity is to allow to specify a condition directly:

Wformat-y2k
C ObjC C++ ObjC++ Var(warn_format_y2k) Warning LangEnabledByCond(C
ObjC C++ ObjC++,Wformat=,warn_format >= 2)
Warn about strftime formats yielding 2-digit years

Wformat-zero-length
C ObjC C++ ObjC++ Var(warn_format_zero_length) Warning
LangEnabledByCond(C ObjC C++ ObjC++,Wformat=,warn_format >= 2)
Warn about zero-length formats

Wformat=
C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Warning

I think this is both flexible and easy to implement given the current
infrastructure. But I wanted to get your approval before. What do you
think?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PR c/53063 Handle Wformat with LangEnabledBy
  2012-10-23 19:38   ` Manuel López-Ibáñez
@ 2012-10-24  0:54     ` Joseph S. Myers
  0 siblings, 0 replies; 6+ messages in thread
From: Joseph S. Myers @ 2012-10-24  0:54 UTC (permalink / raw)
  To: Manuel López-Ibáñez; +Cc: Gcc Patch List

[-- Attachment #1: Type: text/plain, Size: 335 bytes --]

On Tue, 23 Oct 2012, Manuel López-Ibáñez wrote:

> The problem is how to represent that Wformat-y2k is enabled by
> -Wformat=X with X >= 2, while Wformat-zero-length is enabled by X >=1.
> 
> One possiblity is to allow to specify a condition directly:

I guess that's reasonable.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PR c/53063 Handle Wformat with LangEnabledBy
  2012-10-19 16:22 ` Joseph S. Myers
  2012-10-23 19:38   ` Manuel López-Ibáñez
@ 2012-10-27 17:03   ` Manuel López-Ibáñez
  2012-11-03 17:19     ` Joseph S. Myers
  1 sibling, 1 reply; 6+ messages in thread
From: Manuel López-Ibáñez @ 2012-10-27 17:03 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Gcc Patch List

[-- Attachment #1: Type: text/plain, Size: 1805 bytes --]

On 19 October 2012 18:17, Joseph S. Myers <joseph@codesourcery.com> wrote:
> On Wed, 17 Oct 2012, Manuel López-Ibáñez wrote:
>
>> documentation but I can also implement -Wformat=0 being an alias for
>> -Wno-format and -Wformat=1 an alias for -Wformat and simply reject
>> -Wno-format=.
>
> I think that's what's wanted; -Wno-format= should be rejected, -Wformat=
> should take an arbitrary integer level (of which at present all those
> above 2 are equivalent to 2, just as -O<n> for n > 3 is equivalent to
> -O3).

This patch implements exactly that. Bootstrapped and regression tested
on x86_64-linux-gnu. OK?

2012-10-27  Manuel López-Ibáñez  <manu@gcc.gnu.org>

        PR c/53063
gcc/
	* doc/invoke.texi (Wformat): Update.
c-family/
	* c.opt (Wformat): Make it Alias Wformat=1.
	(Wformat-contains-nul,Wformat-extra-args,Wformat-nonliteral,
	Wformat-security,Wformat-y2k,Wformat-zero-length): Use
	LangEnabledBy.
	(Wformat=): RejectNegative. Use LangEnabledBy.
	(Wnonnull): Use LangEnabledBy.
	* c-opts.c (c_common_handle_option): Do not handle Wformat here.
	* c-format.c (decode_format_attr): Replace OPT_Wformat with
	OPT_Wformat_.
        (maybe_read_dollar_number):  Likewise.
        (avoid_dollar_number):  Likewise.
        (finish_dollar_format_checking):  Likewise.
        (check_format_info):  Likewise.
        (check_format_info_main):  Likewise.
        (check_format_types):  Likewise.
        (format_type_warning):  Likewise.
        * c-common.c (int):  Likewise.
        (check_function_sentinel):  Likewise.
        * c-common.h (warn_format): Do not declare here.
testsuite/
	* gcc.dg/warn-nsstring.c: Use -Wformat explicitly.
gcc/
	* optc-gen.awk: Factor code out to...
	* opt-functions.awk (lang_enabled_by): ... this new function.

[-- Attachment #2: wformat.diff --]
[-- Type: application/octet-stream, Size: 33346 bytes --]

Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi	(revision 192761)
+++ gcc/doc/invoke.texi	(working copy)
@@ -3239,14 +3239,16 @@ float area(float radius)
 @end smallexample
 the compiler performs the entire computation with @code{double}
 because the floating-point literal is a @code{double}.
 
 @item -Wformat
+@itemx -Wformat=@var{n}
 @opindex Wformat
 @opindex Wno-format
 @opindex ffreestanding
 @opindex fno-builtin
+@opindex Wformat=
 Check calls to @code{printf} and @code{scanf}, etc., to make sure that
 the arguments supplied have types appropriate to the format string
 specified, and that the conversions specified in the format string make
 sense.  This includes standard functions, and others specified by format
 attributes (@pxref{Function Attributes}), in the @code{printf},
@@ -3266,24 +3268,21 @@ particular library's limitations.  Howev
 with @option{-Wformat}, warnings are given about format features not
 in the selected standard version (but not for @code{strfmon} formats,
 since those are not in any version of the C standard).  @xref{C Dialect
 Options,,Options Controlling C Dialect}.
 
-Since @option{-Wformat} also checks for null format arguments for
-several functions, @option{-Wformat} also implies @option{-Wnonnull}.
-
-@option{-Wformat} is included in @option{-Wall}.  For more control over some
-aspects of format checking, the options @option{-Wformat-y2k},
-@option{-Wno-format-extra-args}, @option{-Wno-format-zero-length},
-@option{-Wformat-nonliteral}, @option{-Wformat-security}, and
-@option{-Wformat=2} are available, but are not included in @option{-Wall}.
-
-@item -Wformat-y2k
-@opindex Wformat-y2k
-@opindex Wno-format-y2k
-If @option{-Wformat} is specified, also warn about @code{strftime}
-formats that may yield only a two-digit year.
+@table @gcctabopt
+@item -Wformat=1
+@itemx -Wformat
+Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
+@option{-Wno-format} is equivalent to @option{-Wformat=0}.  Since
+@option{-Wformat} also checks for null format arguments for several
+functions, @option{-Wformat} also implies @option{-Wnonnull}.  Some
+aspects of this level of format checking can be disabled by the
+options: @option{-Wno-format-contains-nul},
+@option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
+@option{-Wformat} is enabled by @option{-Wall}.
 
 @item -Wno-format-contains-nul
 @opindex Wno-format-contains-nul
 @opindex Wformat-contains-nul
 If @option{-Wformat} is specified, do not warn about format strings that
@@ -3308,10 +3307,16 @@ Unix Specification says that such unused
 @opindex Wno-format-zero-length
 @opindex Wformat-zero-length
 If @option{-Wformat} is specified, do not warn about zero-length formats.
 The C standard specifies that zero-length formats are allowed.
 
+
+@item -Wformat=2
+Enable @option{-Wformat} plus additional format checks.  Currently
+equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security
+-Wformat-y2k}.
+
 @item -Wformat-nonliteral
 @opindex Wformat-nonliteral
 @opindex Wno-format-nonliteral
 If @option{-Wformat} is specified, also warn if the format string is not a
 string literal and so cannot be checked, unless the format function
@@ -3328,16 +3333,16 @@ as in @code{printf (foo);}.  This may be
 string came from untrusted input and contains @samp{%n}.  (This is
 currently a subset of what @option{-Wformat-nonliteral} warns about, but
 in future warnings may be added to @option{-Wformat-security} that are not
 included in @option{-Wformat-nonliteral}.)
 
-@item -Wformat=2
-@opindex Wformat=2
-@opindex Wno-format=2
-Enable @option{-Wformat} plus format checks not included in
-@option{-Wformat}.  Currently equivalent to @option{-Wformat
--Wformat-nonliteral -Wformat-security -Wformat-y2k}.
+@item -Wformat-y2k
+@opindex Wformat-y2k
+@opindex Wno-format-y2k
+If @option{-Wformat} is specified, also warn about @code{strftime}
+formats that may yield only a two-digit year.
+@end table
 
 @item -Wnonnull
 @opindex Wnonnull
 @opindex Wno-nonnull
 Warn about passing a null pointer for arguments marked as
@@ -3788,11 +3793,10 @@ cases, but does attempt to catch the mor
 included in @option{-Wall}.
 It is equivalent to @option{-Wstrict-aliasing=3}
 
 @item -Wstrict-aliasing=n
 @opindex Wstrict-aliasing=n
-@opindex Wno-strict-aliasing=n
 This option is only active when @option{-fstrict-aliasing} is active.
 It warns about code that might break the strict aliasing rules that the
 compiler is using for optimization.
 Higher levels correspond to higher accuracy (fewer false positives).
 Higher levels also correspond to more effort, similar to the way @option{-O} 
Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt	(revision 192761)
+++ gcc/c-family/c.opt	(working copy)
@@ -367,39 +367,40 @@ This switch is deprecated; use -Werror=i
 Wfloat-equal
 C ObjC C++ ObjC++ Var(warn_float_equal) Warning
 Warn if testing floating point numbers for equality
 
 Wformat
-C ObjC C++ ObjC++ Warning
+C ObjC C++ ObjC++ Warning Alias(Wformat=, 1, 0)
 Warn about printf/scanf/strftime/strfmon format string anomalies
 
+Wformat-contains-nul
+C ObjC C++ ObjC++ Var(warn_format_contains_nul) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 1, 0)
+Warn about format strings that contain NUL bytes
+
 Wformat-extra-args
-C ObjC C++ ObjC++ Var(warn_format_extra_args) Warning
+C ObjC C++ ObjC++ Var(warn_format_extra_args) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 1, 0)
 Warn if passing too many arguments to a function for its format string
 
 Wformat-nonliteral
-C ObjC C++ ObjC++ Var(warn_format_nonliteral) Warning
+C ObjC C++ ObjC++ Var(warn_format_nonliteral) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 2, 0)
 Warn about format strings that are not literals
 
-Wformat-contains-nul
-C ObjC C++ ObjC++ Var(warn_format_contains_nul) Warning
-Warn about format strings that contain NUL bytes
-
 Wformat-security
-C ObjC C++ ObjC++ Var(warn_format_security) Warning
+C ObjC C++ ObjC++ Var(warn_format_security) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 2, 0)
 Warn about possible security problems with format functions
 
 Wformat-y2k
-C ObjC C++ ObjC++ Var(warn_format_y2k) Warning
+C ObjC C++ ObjC++ Var(warn_format_y2k) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=,warn_format >= 2, 0)
 Warn about strftime formats yielding 2-digit years
 
 Wformat-zero-length
-C ObjC C++ ObjC++ Var(warn_format_zero_length) Warning
+C ObjC C++ ObjC++ Var(warn_format_zero_length) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=,warn_format >= 1, 0)
 Warn about zero-length formats
 
 Wformat=
-C ObjC C++ ObjC++ Joined Warning
+C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0)
+Warn about printf/scanf/strftime/strfmon format string anomalies
 
 Wignored-qualifiers
 C C++ Var(warn_ignored_qualifiers) Warning EnabledBy(Wextra)
 Warn whenever type qualifiers are ignored.
 
@@ -524,13 +525,17 @@ Warn when non-templatized friend functio
 Wnon-virtual-dtor
 C++ ObjC++ Var(warn_nonvdtor) Warning
 Warn about non-virtual destructors
 
 Wnonnull
-C ObjC C++ ObjC++ Var(warn_nonnull) Warning
+C ObjC C++ ObjC++ Var(warn_nonnull) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=,warn_format >= 1,0)
 Warn about NULL being passed to argument slots marked as requiring non-NULL
 
+Wnonnull
+C ObjC C++ ObjC++ LangEnabledBy(C ObjC C++ ObjC++,Wall)
+;
+
 Wnormalized=
 C ObjC C++ ObjC++ Joined Warning
 -Wnormalized=<id|nfc|nfkc>	Warn about non-normalised Unicode strings
 
 Wold-style-cast
Index: gcc/c-family/c-opts.c
===================================================================
--- gcc/c-family/c-opts.c	(revision 192761)
+++ gcc/c-family/c-opts.c	(working copy)
@@ -362,11 +362,10 @@ c_common_handle_option (size_t scode, co
       defer_opt (code, arg);
       break;
 
     case OPT_Wall:
       /* ??? Don't add new options here. Use LangEnabledBy in c.opt.  */
-      set_Wformat (value);
       warn_switch = value;
       warn_array_bounds = value;
 
       /* Only warn about unknown pragmas that are not in system
 	 headers.  */
@@ -413,18 +412,10 @@ c_common_handle_option (size_t scode, co
 
     case OPT_Wendif_labels:
       cpp_opts->warn_endif_labels = value;
       break;
 
-    case OPT_Wformat:
-      set_Wformat (value);
-      break;
-
-    case OPT_Wformat_:
-      set_Wformat (atoi (arg));
-      break;
-
     case OPT_Winvalid_pch:
       cpp_opts->warn_invalid_pch = value;
       break;
 
     case OPT_Wliteral_suffix:
Index: gcc/c-family/c-format.c
===================================================================
--- gcc/c-family/c-format.c	(revision 192761)
+++ gcc/c-family/c-format.c	(working copy)
@@ -291,20 +291,20 @@ decode_format_attr (tree args, function_
       
       if (!c_dialect_objc ()
 	   && info->format_type == gcc_objc_string_format_type)
 	{
 	  gcc_assert (!validated_p);
-	  warning (OPT_Wformat, "%qE is only allowed in Objective-C dialects",
+	  warning (OPT_Wformat_, "%qE is only allowed in Objective-C dialects",
 		   format_type_id);
 	  info->format_type = format_type_error;
 	  return false;
 	}
 
       if (info->format_type == format_type_error)
 	{
 	  gcc_assert (!validated_p);
-	  warning (OPT_Wformat, "%qE is an unrecognized format function type",
+	  warning (OPT_Wformat_, "%qE is an unrecognized format function type",
 		   format_type_id);
 	  return false;
 	}
     }
 
@@ -1151,11 +1151,11 @@ maybe_read_dollar_number (const char **f
   const char *fcp = *format;
   if (!ISDIGIT (*fcp))
     {
       if (dollar_needed)
 	{
-	  warning (OPT_Wformat, "missing $ operand number in format");
+	  warning (OPT_Wformat_, "missing $ operand number in format");
 	  return -1;
 	}
       else
 	return 0;
     }
@@ -1172,27 +1172,27 @@ maybe_read_dollar_number (const char **f
     }
   if (*fcp != '$')
     {
       if (dollar_needed)
 	{
-	  warning (OPT_Wformat, "missing $ operand number in format");
+	  warning (OPT_Wformat_, "missing $ operand number in format");
 	  return -1;
 	}
       else
 	return 0;
     }
   *format = fcp + 1;
   if (pedantic && !dollar_format_warned)
     {
-      warning (OPT_Wformat, "%s does not support %%n$ operand number formats",
+      warning (OPT_Wformat_, "%s does not support %%n$ operand number formats",
 	       C_STD_NAME (STD_EXT));
       dollar_format_warned = 1;
     }
   if (overflow_flag || argnum == 0
       || (dollar_first_arg_num && argnum > dollar_arguments_count))
     {
-      warning (OPT_Wformat, "operand number out of range in format");
+      warning (OPT_Wformat_, "operand number out of range in format");
       return -1;
     }
   if (argnum > dollar_max_arg_used)
     dollar_max_arg_used = argnum;
   /* For vprintf-style functions we may need to allocate more memory to
@@ -1211,11 +1211,11 @@ maybe_read_dollar_number (const char **f
     }
   if (!(fki->flags & (int) FMT_FLAG_DOLLAR_MULTIPLE)
       && dollar_arguments_used[argnum - 1] == 1)
     {
       dollar_arguments_used[argnum - 1] = 2;
-      warning (OPT_Wformat, "format argument %d used more than once in %s format",
+      warning (OPT_Wformat_, "format argument %d used more than once in %s format",
 	       argnum, fki->name);
     }
   else
     dollar_arguments_used[argnum - 1] = 1;
   if (dollar_first_arg_num)
@@ -1243,11 +1243,11 @@ avoid_dollar_number (const char *format)
     return false;
   while (ISDIGIT (*format))
     format++;
   if (*format == '$')
     {
-      warning (OPT_Wformat, "$ operand number used after format without operand number");
+      warning (OPT_Wformat_, "$ operand number used after format without operand number");
       return true;
     }
   return false;
 }
 
@@ -1273,11 +1273,11 @@ finish_dollar_format_checking (format_ch
 	{
 	  if (pointer_gap_ok && (dollar_first_arg_num == 0
 				 || dollar_arguments_pointer_p[i]))
 	    found_pointer_gap = true;
 	  else
-	    warning (OPT_Wformat,
+	    warning (OPT_Wformat_,
 		     "format argument %d unused before used argument %d in $-style format",
 		     i + 1, dollar_max_arg_used);
 	}
     }
   if (found_pointer_gap
@@ -1413,14 +1413,14 @@ check_format_info (function_format_info 
       && res.number_other == 0)
     warning (OPT_Wformat_zero_length, "zero-length %s format string",
 	     format_types[info->format_type].name);
 
   if (res.number_wide > 0)
-    warning (OPT_Wformat, "format is a wide character string");
+    warning (OPT_Wformat_, "format is a wide character string");
 
   if (res.number_unterminated > 0)
-    warning (OPT_Wformat, "unterminated format string");
+    warning (OPT_Wformat_, "unterminated format string");
 }
 
 /* Callback from check_function_arguments_recurse to check a
    format string.  FORMAT_TREE is the format parameter.  ARG_NUM
    is the number of the format argument.  CTX points to a
@@ -1660,11 +1660,11 @@ check_format_info_main (format_check_res
 
       if (*format_chars++ != '%')
 	continue;
       if (*format_chars == 0)
 	{
-	  warning (OPT_Wformat, "spurious trailing %<%%%> in format");
+	  warning (OPT_Wformat_, "spurious trailing %<%%%> in format");
 	  continue;
 	}
       if (*format_chars == '%')
 	{
 	  ++format_chars;
@@ -1704,11 +1704,11 @@ check_format_info_main (format_check_res
 	{
 	  const format_flag_spec *s = get_flag_spec (flag_specs,
 						     *format_chars, NULL);
 	  if (strchr (flag_chars, *format_chars) != 0)
 	    {
-	      warning (OPT_Wformat, "repeated %s in format", _(s->name));
+	      warning (OPT_Wformat_, "repeated %s in format", _(s->name));
 	    }
 	  else
 	    {
 	      i = strlen (flag_chars);
 	      flag_chars[i++] = *format_chars;
@@ -1717,11 +1717,11 @@ check_format_info_main (format_check_res
 	  if (s->skip_next_char)
 	    {
 	      ++format_chars;
 	      if (*format_chars == 0)
 		{
-		  warning (OPT_Wformat, "missing fill character at end of strfmon format");
+		  warning (OPT_Wformat_, "missing fill character at end of strfmon format");
 		  return;
 		}
 	    }
 	  ++format_chars;
 	}
@@ -1805,11 +1805,11 @@ check_format_info_main (format_check_res
 		    non_zero_width_char = TRUE;
 		  ++format_chars;
 		}
 	      if (found_width && !non_zero_width_char &&
 		  (fki->flags & (int) FMT_FLAG_ZERO_WIDTH_BAD))
-		warning (OPT_Wformat, "zero width in %s format", fki->name);
+		warning (OPT_Wformat_, "zero width in %s format", fki->name);
 	      if (found_width)
 		{
 		  i = strlen (flag_chars);
 		  flag_chars[i++] = fki->width_char;
 		  flag_chars[i] = 0;
@@ -1823,11 +1823,11 @@ check_format_info_main (format_check_res
 	  ++format_chars;
 	  i = strlen (flag_chars);
 	  flag_chars[i++] = fki->left_precision_char;
 	  flag_chars[i] = 0;
 	  if (!ISDIGIT (*format_chars))
-	    warning (OPT_Wformat, "empty left precision in %s format", fki->name);
+	    warning (OPT_Wformat_, "empty left precision in %s format", fki->name);
 	  while (ISDIGIT (*format_chars))
 	    ++format_chars;
 	}
 
       /* Read any format precision, possibly * or *m$.  */
@@ -1899,11 +1899,11 @@ check_format_info_main (format_check_res
 	    }
 	  else
 	    {
 	      if (!(fki->flags & (int) FMT_FLAG_EMPTY_PREC_OK)
 		  && !ISDIGIT (*format_chars))
-		warning (OPT_Wformat, "empty precision in %s format", fki->name);
+		warning (OPT_Wformat_, "empty precision in %s format", fki->name);
 	      while (ISDIGIT (*format_chars))
 		++format_chars;
 	    }
 	}
 
@@ -1967,11 +1967,11 @@ check_format_info_main (format_check_res
 	    }
 	  if (pedantic)
 	    {
 	      /* Warn if the length modifier is non-standard.  */
 	      if (ADJ_STD (length_chars_std) > C_STD_VER)
-		warning (OPT_Wformat,
+		warning (OPT_Wformat_,
 			 "%s does not support the %qs %s length modifier",
 			 C_STD_NAME (length_chars_std), length_chars,
 			 fki->name);
 	    }
 	}
@@ -1984,11 +1984,11 @@ check_format_info_main (format_check_res
 	    {
 	      if (strchr (flag_chars, *format_chars) != 0)
 		{
 		  const format_flag_spec *s = get_flag_spec (flag_specs,
 							     *format_chars, NULL);
-		  warning (OPT_Wformat, "repeated %s in format", _(s->name));
+		  warning (OPT_Wformat_, "repeated %s in format", _(s->name));
 		}
 	      else
 		{
 		  i = strlen (flag_chars);
 		  flag_chars[i++] = *format_chars;
@@ -2001,32 +2001,32 @@ check_format_info_main (format_check_res
       format_char = *format_chars;
       if (format_char == 0
 	  || (!(fki->flags & (int) FMT_FLAG_FANCY_PERCENT_OK)
 	      && format_char == '%'))
 	{
-	  warning (OPT_Wformat, "conversion lacks type at end of format");
+	  warning (OPT_Wformat_, "conversion lacks type at end of format");
 	  continue;
 	}
       format_chars++;
       fci = fki->conversion_specs;
       while (fci->format_chars != 0
 	     && strchr (fci->format_chars, format_char) == 0)
 	  ++fci;
       if (fci->format_chars == 0)
 	{
 	  if (ISGRAPH (format_char))
-	    warning (OPT_Wformat, "unknown conversion type character %qc in format",
+	    warning (OPT_Wformat_, "unknown conversion type character %qc in format",
 		     format_char);
 	  else
-	    warning (OPT_Wformat, "unknown conversion type character 0x%x in format",
+	    warning (OPT_Wformat_, "unknown conversion type character 0x%x in format",
 		     format_char);
 	  continue;
 	}
       if (pedantic)
 	{
 	  if (ADJ_STD (fci->std) > C_STD_VER)
-	    warning (OPT_Wformat, "%s does not support the %<%%%c%> %s format",
+	    warning (OPT_Wformat_, "%s does not support the %<%%%c%> %s format",
 		     C_STD_NAME (fci->std), format_char, fki->name);
 	}
 
       /* Validate the individual flags used, removing any that are invalid.  */
       {
@@ -2038,29 +2038,29 @@ check_format_info_main (format_check_res
 	    flag_chars[i - d] = flag_chars[i];
 	    if (flag_chars[i] == fki->length_code_char)
 	      continue;
 	    if (strchr (fci->flag_chars, flag_chars[i]) == 0)
 	      {
-		warning (OPT_Wformat, "%s used with %<%%%c%> %s format",
+		warning (OPT_Wformat_, "%s used with %<%%%c%> %s format",
 			 _(s->name), format_char, fki->name);
 		d++;
 		continue;
 	      }
 	    if (pedantic)
 	      {
 		const format_flag_spec *t;
 		if (ADJ_STD (s->std) > C_STD_VER)
-		  warning (OPT_Wformat, "%s does not support %s",
+		  warning (OPT_Wformat_, "%s does not support %s",
 			   C_STD_NAME (s->std), _(s->long_name));
 		t = get_flag_spec (flag_specs, flag_chars[i], fci->flags2);
 		if (t != NULL && ADJ_STD (t->std) > ADJ_STD (s->std))
 		  {
 		    const char *long_name = (t->long_name != NULL
 					     ? t->long_name
 					     : s->long_name);
 		    if (ADJ_STD (t->std) > C_STD_VER)
-		      warning (OPT_Wformat,
+		      warning (OPT_Wformat_,
 			       "%s does not support %s with the %<%%%c%> %s format",
 			       C_STD_NAME (t->std), _(long_name),
 			       format_char, fki->name);
 		  }
 	      }
@@ -2092,27 +2092,27 @@ check_format_info_main (format_check_res
 	  s = get_flag_spec (flag_specs, bad_flag_pairs[i].flag_char1, NULL);
 	  t = get_flag_spec (flag_specs, bad_flag_pairs[i].flag_char2, NULL);
 	  if (bad_flag_pairs[i].ignored)
 	    {
 	      if (bad_flag_pairs[i].predicate != 0)
-		warning (OPT_Wformat,
+		warning (OPT_Wformat_,
 			 "%s ignored with %s and %<%%%c%> %s format",
 			 _(s->name), _(t->name), format_char,
 			 fki->name);
 	      else
-		warning (OPT_Wformat, "%s ignored with %s in %s format",
+		warning (OPT_Wformat_, "%s ignored with %s in %s format",
 			 _(s->name), _(t->name), fki->name);
 	    }
 	  else
 	    {
 	      if (bad_flag_pairs[i].predicate != 0)
-		warning (OPT_Wformat,
+		warning (OPT_Wformat_,
 			 "use of %s and %s together with %<%%%c%> %s format",
 			 _(s->name), _(t->name), format_char,
 			 fki->name);
 	      else
-		warning (OPT_Wformat, "use of %s and %s together in %s format",
+		warning (OPT_Wformat_, "use of %s and %s together in %s format",
 			 _(s->name), _(t->name), fki->name);
 	    }
 	}
 
       /* Give Y2K warnings.  */
@@ -2147,11 +2147,11 @@ check_format_info_main (format_check_res
 	    ++format_chars;
 	  while (*format_chars && *format_chars != ']')
 	    ++format_chars;
 	  if (*format_chars != ']')
 	    /* The end of the format string was reached.  */
-	    warning (OPT_Wformat, "no closing %<]%> for %<%%[%> format");
+	    warning (OPT_Wformat_, "no closing %<]%> for %<%%[%> format");
 	}
 
       wanted_type = 0;
       wanted_type_name = 0;
       if (fki->flags & (int) FMT_FLAG_ARG_CONVERT)
@@ -2160,11 +2160,11 @@ check_format_info_main (format_check_res
 			 ? *fci->types[length_chars_val].type : 0);
 	  wanted_type_name = fci->types[length_chars_val].name;
 	  wanted_type_std = fci->types[length_chars_val].std;
 	  if (wanted_type == 0)
 	    {
-	      warning (OPT_Wformat,
+	      warning (OPT_Wformat_,
 		       "use of %qs length modifier with %qc type character",
 		       length_chars, format_char);
 	      /* Heuristic: skip one argument when an invalid length/type
 		 combination is encountered.  */
 	      arg_num++;
@@ -2178,11 +2178,11 @@ check_format_info_main (format_check_res
 		      have been warned for.  */
 		   && ADJ_STD (wanted_type_std) > ADJ_STD (length_chars_std)
 		   && ADJ_STD (wanted_type_std) > ADJ_STD (fci->std))
 	    {
 	      if (ADJ_STD (wanted_type_std) > C_STD_VER)
-		warning (OPT_Wformat,
+		warning (OPT_Wformat_,
 			 "%s does not support the %<%%%s%c%> %s format",
 			 C_STD_NAME (wanted_type_std), length_chars,
 			 format_char, fki->name);
 	    }
 	}
@@ -2196,14 +2196,14 @@ check_format_info_main (format_check_res
 	  || suppressed)
 	{
 	  if (main_arg_num != 0)
 	    {
 	      if (suppressed)
-		warning (OPT_Wformat, "operand number specified with "
+		warning (OPT_Wformat_, "operand number specified with "
 			 "suppressed assignment");
 	      else
-		warning (OPT_Wformat, "operand number specified for format "
+		warning (OPT_Wformat_, "operand number specified for format "
 			 "taking no argument");
 	    }
 	}
       else
 	{
@@ -2217,11 +2217,11 @@ check_format_info_main (format_check_res
 	  else
 	    {
 	      ++arg_num;
 	      if (has_operand_number > 0)
 		{
-		  warning (OPT_Wformat, "missing $ operand number in format");
+		  warning (OPT_Wformat_, "missing $ operand number in format");
 		  return;
 		}
 	      else
 		has_operand_number = 0;
 	    }
@@ -2353,19 +2353,19 @@ check_format_types (format_wanted_type *
 	      /* Check for writing through a NULL pointer.  */
 	      if (types->writing_in_flag
 		  && i == 0
 		  && cur_param != 0
 		  && integer_zerop (cur_param))
-		warning (OPT_Wformat, "writing through null pointer "
+		warning (OPT_Wformat_, "writing through null pointer "
 			 "(argument %d)", arg_num);
 
 	      /* Check for reading through a NULL pointer.  */
 	      if (types->reading_from_flag
 		  && i == 0
 		  && cur_param != 0
 		  && integer_zerop (cur_param))
-		warning (OPT_Wformat, "reading through null pointer "
+		warning (OPT_Wformat_, "reading through null pointer "
 			 "(argument %d)", arg_num);
 
 	      if (cur_param != 0 && TREE_CODE (cur_param) == ADDR_EXPR)
 		cur_param = TREE_OPERAND (cur_param, 0);
 	      else
@@ -2381,22 +2381,22 @@ check_format_types (format_wanted_type *
 		  && (TYPE_READONLY (cur_type)
 		      || (cur_param != 0
 			  && (CONSTANT_CLASS_P (cur_param)
 			      || (DECL_P (cur_param)
 				  && TREE_READONLY (cur_param))))))
-		warning (OPT_Wformat, "writing into constant object "
+		warning (OPT_Wformat_, "writing into constant object "
 			 "(argument %d)", arg_num);
 
 	      /* If there are extra type qualifiers beyond the first
 		 indirection, then this makes the types technically
 		 incompatible.  */
 	      if (i > 0
 		  && pedantic
 		  && (TYPE_READONLY (cur_type)
 		      || TYPE_VOLATILE (cur_type)
 		      || TYPE_RESTRICT (cur_type)))
-		warning (OPT_Wformat, "extra type qualifiers in format "
+		warning (OPT_Wformat_, "extra type qualifiers in format "
 			 "argument (argument %d)",
 			 arg_num);
 
 	    }
 	  else
@@ -2508,33 +2508,33 @@ format_type_warning (format_wanted_type 
     }
 
   if (wanted_type_name)
     {
       if (arg_type)
-        warning (OPT_Wformat, "%s %<%s%.*s%> expects argument of type %<%s%s%>, "
+        warning (OPT_Wformat_, "%s %<%s%.*s%> expects argument of type %<%s%s%>, "
                  "but argument %d has type %qT",
                  gettext (kind_descriptions[kind]),
                  (kind == CF_KIND_FORMAT ? "%" : ""),
                  format_length, format_start, 
                  wanted_type_name, p, arg_num, arg_type);
       else
-        warning (OPT_Wformat, "%s %<%s%.*s%> expects a matching %<%s%s%> argument",
+        warning (OPT_Wformat_, "%s %<%s%.*s%> expects a matching %<%s%s%> argument",
                  gettext (kind_descriptions[kind]),
                  (kind == CF_KIND_FORMAT ? "%" : ""),
                  format_length, format_start, wanted_type_name, p);
     }
   else
     {
       if (arg_type)
-        warning (OPT_Wformat, "%s %<%s%.*s%> expects argument of type %<%T%s%>, "
+        warning (OPT_Wformat_, "%s %<%s%.*s%> expects argument of type %<%T%s%>, "
                  "but argument %d has type %qT",
                  gettext (kind_descriptions[kind]),
                  (kind == CF_KIND_FORMAT ? "%" : ""),
                  format_length, format_start, 
                  wanted_type, p, arg_num, arg_type);
       else
-        warning (OPT_Wformat, "%s %<%s%.*s%> expects a matching %<%T%s%> argument",
+        warning (OPT_Wformat_, "%s %<%s%.*s%> expects a matching %<%T%s%> argument",
                  gettext (kind_descriptions[kind]),
                  (kind == CF_KIND_FORMAT ? "%" : ""),
                  format_length, format_start, wanted_type, p);
     }
 }
Index: gcc/c-family/c-common.c
===================================================================
--- gcc/c-family/c-common.c	(revision 192761)
+++ gcc/c-family/c-common.c	(working copy)
@@ -195,15 +195,10 @@ int flag_iso;
 
 /* Warn about #pragma directives that are not recognized.  */
 
 int warn_unknown_pragmas; /* Tri state variable.  */
 
-/* Warn about format/argument anomalies in calls to formatted I/O functions
-   (*printf, *scanf, strftime, strfmon, etc.).  */
-
-int warn_format;
-
 /* C/ObjC language option variables.  */
 
 
 /* Nonzero means allow type mismatches in conditional expressions;
    just make their values `void'.  */
@@ -8505,11 +8500,11 @@ check_function_sentinel (const_tree fnty
 
       /* The sentinel must be one of the varargs, i.e.
 	 in position >= the number of fixed arguments.  */
       if ((nargs - 1 - pos) < len)
 	{
-	  warning (OPT_Wformat,
+	  warning (OPT_Wformat_,
 		   "not enough variable arguments to fit a sentinel");
 	  return;
 	}
 
       /* Validate the sentinel.  */
@@ -8520,11 +8515,11 @@ check_function_sentinel (const_tree fnty
 	     nevertheless, as we are guaranteed that it's exactly
 	     as wide as a pointer, and we don't want to force
 	     users to cast the NULL they have written there.
 	     We warn with -Wstrict-null-sentinel, though.  */
 	  && (warn_strict_null_sentinel || null_node != sentinel))
-	warning (OPT_Wformat, "missing sentinel in function call");
+	warning (OPT_Wformat_, "missing sentinel in function call");
     }
 }
 
 /* Helper for check_function_nonnull; given a list of operands which
    must be non-null in ARGS, determine if operand PARAM_NUM should be
Index: gcc/c-family/c-common.h
===================================================================
--- gcc/c-family/c-common.h	(revision 192761)
+++ gcc/c-family/c-common.h	(working copy)
@@ -587,16 +587,10 @@ extern int flag_iso;
 
 /* Warn about #pragma directives that are not recognized.  */
 
 extern int warn_unknown_pragmas; /* Tri state variable.  */
 
-/* Warn about format/argument anomalies in calls to formatted I/O functions
-   (*printf, *scanf, strftime, strfmon, etc.).  */
-
-extern int warn_format;
-
-
 /* C/ObjC language option variables.  */
 
 
 /* Nonzero means allow type mismatches in conditional expressions;
    just make their values `void'.  */
@@ -734,11 +728,10 @@ extern void check_function_arguments_rec
 					       unsigned HOST_WIDE_INT),
 					      void *, tree,
 					      unsigned HOST_WIDE_INT);
 extern bool check_builtin_function_arguments (tree, int, tree *);
 extern void check_function_format (tree, int, tree *);
-extern void set_Wformat (int);
 extern tree handle_format_attribute (tree *, tree, tree, int, bool *);
 extern tree handle_format_arg_attribute (tree *, tree, tree, int, bool *);
 extern bool attribute_takes_identifier_p (const_tree);
 extern bool c_common_handle_option (size_t, const char *, int, int, location_t,
 				    const struct cl_option_handlers *);
Index: gcc/testsuite/gcc.dg/warn-nsstring.c
===================================================================
--- gcc/testsuite/gcc.dg/warn-nsstring.c	(revision 192761)
+++ gcc/testsuite/gcc.dg/warn-nsstring.c	(working copy)
@@ -1,7 +1,7 @@
 /* Check that the NSString format extension is rejected in c.  */
 /* { dg-do compile } */
-
+/* { dg-options "-Wformat" } */
 extern void NSLog (void *fmt, ...) __attribute__((format(__NSString__, 1, 2))); /* { dg-warning "is only allowed in Objective-C dialects" } */
 extern void NSLog1 (void *fmt, ...) __attribute__((format(NSString, 1, 2))); /* { dg-warning "is only allowed in Objective-C dialects" } */
 
 
Index: gcc/optc-gen.awk
===================================================================
--- gcc/optc-gen.awk	(revision 192761)
+++ gcc/optc-gen.awk	(working copy)
@@ -71,36 +71,15 @@ for (i = 0; i < n_opts; i++) {
         }
     }
 
     enabledby_arg = opt_args("LangEnabledBy", flags[i]);
     if (enabledby_arg != "") {
-        n_enabledby_arg_langs = split(nth_arg(0, enabledby_arg), enabledby_arg_langs, " ");
+        enabledby_langs = nth_arg(0, enabledby_arg);
         enabledby_name = nth_arg(1, enabledby_arg);
-        enabledby_posarg = nth_arg(2, enabledby_arg)
-	enabledby_negarg = nth_arg(3, enabledby_arg)
-        enabledby_index = opt_numbers[enabledby_name];
-        if (enabledby_index == "") {
-            print "#error LangEnabledby: " enabledby_name 
-        } else {
-            if (enabledby_posarg != "" && enabledby_negarg != "") {
-                with_args = "," enabledby_posarg "," enabledby_negarg
-            } else if (enabledby_posarg == "" && enabledby_negarg == "") {
-                with_args = ""
-            } else {
-                print "#error LangEnabledBy with three arguments, it should have either 2 or 4"
-            }
-
-            for (j = 1; j <= n_enabledby_arg_langs; j++) {
-                lang_name = lang_sanitized_name(enabledby_arg_langs[j]);
-                lang_index = lang_numbers[enabledby_arg_langs[j]];
-                if (enables[lang_name,enabledby_name] == "") {
-                    enabledby[lang_name,n_enabledby_lang[lang_index]] = enabledby_name;
-                    n_enabledby_lang[lang_index]++;
-                }
-                enables[lang_name,enabledby_name] = enables[lang_name,enabledby_name] opts[i] with_args ";";
-            }
-        }
+        enabledby_posarg = nth_arg(2, enabledby_arg);
+	enabledby_negarg = nth_arg(3, enabledby_arg);
+        lang_enabled_by(enabledby_langs, enabledby_name, enabledby_posarg, enabledby_negarg);
     }
 }
 
 
 print "/* This file is auto-generated by optc-gen.awk.  */"
Index: gcc/opt-functions.awk
===================================================================
--- gcc/opt-functions.awk	(revision 192761)
+++ gcc/opt-functions.awk	(working copy)
@@ -311,5 +311,37 @@ function search_var_name(name, opt_numbe
             return var_name(flags[k]);
         }
     }
     return ""
 }
+
+# Handle LangEnabledBy(ENABLED_BY_LANGS, ENABLEDBY_NAME, ENABLEDBY_POSARG,
+# ENABLEDBY_NEGARG). This function does not return anything.
+function lang_enabled_by(enabledby_langs, enabledby_name, enabledby_posarg, enabledby_negarg)
+{
+    n_enabledby_arg_langs = split(enabledby_langs, enabledby_arg_langs, " ");
+    enabledby_index = opt_numbers[enabledby_name];
+    if (enabledby_index == "") {
+        print "#error LangEnabledby: " enabledby_name 
+    } else {
+        if (enabledby_posarg != "" && enabledby_negarg != "") {
+            with_args = "," enabledby_posarg "," enabledby_negarg
+        } else if (enabledby_posarg == "" && enabledby_negarg == "") {
+            with_args = ""
+        } else {
+            print "#error LangEnabledBy("enabledby_langs","enabledby_name", " \
+                enabledby_posarg", " enabledby_negargs                  \
+                ") with three arguments, it should have either 2 or 4"
+        }
+        
+        for (j = 1; j <= n_enabledby_arg_langs; j++) {
+            lang_name = lang_sanitized_name(enabledby_arg_langs[j]);
+            lang_index = lang_numbers[enabledby_arg_langs[j]];
+            if (enables[lang_name,enabledby_name] == "") {
+                enabledby[lang_name,n_enabledby_lang[lang_index]] = enabledby_name;
+                n_enabledby_lang[lang_index]++;
+            }
+            enables[lang_name,enabledby_name] = enables[lang_name,enabledby_name] opts[i] with_args ";";
+        }
+    }
+}
+

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PR c/53063 Handle Wformat with LangEnabledBy
  2012-10-27 17:03   ` Manuel López-Ibáñez
@ 2012-11-03 17:19     ` Joseph S. Myers
  0 siblings, 0 replies; 6+ messages in thread
From: Joseph S. Myers @ 2012-11-03 17:19 UTC (permalink / raw)
  To: Manuel López-Ibáñez; +Cc: Gcc Patch List

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="X-UNKNOWN", Size: 893 bytes --]

On Sat, 27 Oct 2012, Manuel López-Ibáñez wrote:

> On 19 October 2012 18:17, Joseph S. Myers <joseph@codesourcery.com> wrote:
> > On Wed, 17 Oct 2012, Manuel López-Ibáñez wrote:
> >
> >> documentation but I can also implement -Wformat=0 being an alias for
> >> -Wno-format and -Wformat=1 an alias for -Wformat and simply reject
> >> -Wno-format=.
> >
> > I think that's what's wanted; -Wno-format= should be rejected, -Wformat=
> > should take an arbitrary integer level (of which at present all those
> > above 2 are equivalent to 2, just as -O<n> for n > 3 is equivalent to
> > -O3).
> 
> This patch implements exactly that. Bootstrapped and regression tested
> on x86_64-linux-gnu. OK?

OK, but unless there is a dependency between the opt*.awk refactoring and 
the c-family changes, please make those two separate commits.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-11-03 17:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-17 22:24 PR c/53063 Handle Wformat with LangEnabledBy Manuel López-Ibáñez
2012-10-19 16:22 ` Joseph S. Myers
2012-10-23 19:38   ` Manuel López-Ibáñez
2012-10-24  0:54     ` Joseph S. Myers
2012-10-27 17:03   ` Manuel López-Ibáñez
2012-11-03 17:19     ` Joseph S. Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).