Re: PR c/53063 Handle Wformat with LangEnabledBy
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
Re: PR c/53063 Handle Wformat with LangEnabledBy
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
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
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
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
PR c/53063 Handle Wformat with LangEnabledBy
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 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. wformat.diff Description: Binary data