Re: PR c/53063 Handle Wformat with LangEnabledBy

2012-10-19 Thread Joseph S. Myers
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 for n > 3 is equivalent to 
-O3).

-- 
Joseph S. Myers
jos...@codesourcery.com

Re: PR c/53063 Handle Wformat with LangEnabledBy

2012-10-23 Thread Manuel López-Ibáñez
On 19 October 2012 18:17, Joseph S. Myers  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 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?


Re: PR c/53063 Handle Wformat with LangEnabledBy

2012-10-23 Thread Joseph S. Myers
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
jos...@codesourcery.com

Re: PR c/53063 Handle Wformat with LangEnabledBy

2012-10-27 Thread Manuel López-Ibáñez
On 19 October 2012 18:17, Joseph S. Myers  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 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  

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.


wformat.diff
Description: Binary data


Re: PR c/53063 Handle Wformat with LangEnabledBy

2012-11-03 Thread Joseph S. Myers
On Sat, 27 Oct 2012, Manuel L?pez-Ib??ez wrote:

> On 19 October 2012 18:17, Joseph S. Myers  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 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
jos...@codesourcery.com