re PR c/53063 (encode group options in the .opt files)

gcc/
2012-11-07  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c/53063
	* doc/invoke.texi (Wformat): Update.
c-family/
2012-11-07  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c/53063
	* 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 (set_Wformat): Delete.
	(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,set_Wformat): Do not declare here.
testsuite/
2012-11-07  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c/53063
	* gcc.dg/warn-nsstring.c: Use -Wformat explicitly.

From-SVN: r193304
parent 0829c7f7
2012-11-07 Manuel López-Ibáñez <manu@gcc.gnu.org> 2012-11-07 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/53063
* doc/invoke.texi (Wformat): Update.
2012-11-07 Manuel López-Ibáñez <manu@gcc.gnu.org>
* optc-gen.awk: Factor code out to... * optc-gen.awk: Factor code out to...
* opt-functions.awk (lang_enabled_by): ... this new function. * opt-functions.awk (lang_enabled_by): ... this new function.
2012-11-07 Manuel López-Ibáñez <manu@gcc.gnu.org> 2012-11-07 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/53063 PR c/53063
* 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 (set_Wformat): Delete.
(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,set_Wformat): Do not declare here.
2012-11-07 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/53063
* c.opt(Warray-bounds,Wdelete-non-virtual-dtor,Wenum-compare, * c.opt(Warray-bounds,Wdelete-non-virtual-dtor,Wenum-compare,
Wmain,Woverlength-strings, Wunknown-pragmas,Wunused-macros): Wmain,Woverlength-strings, Wunknown-pragmas,Wunused-macros):
Use LangEnabledBy. Use LangEnabledBy.
......
...@@ -193,11 +193,6 @@ const char *pch_file; ...@@ -193,11 +193,6 @@ const char *pch_file;
user's namespace. */ user's namespace. */
int flag_iso; int flag_iso;
/* 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. */ /* C/ObjC language option variables. */
...@@ -8495,7 +8490,7 @@ check_function_sentinel (const_tree fntype, int nargs, tree *argarray) ...@@ -8495,7 +8490,7 @@ check_function_sentinel (const_tree fntype, int nargs, tree *argarray)
in position >= the number of fixed arguments. */ in position >= the number of fixed arguments. */
if ((nargs - 1 - pos) < len) if ((nargs - 1 - pos) < len)
{ {
warning (OPT_Wformat, warning (OPT_Wformat_,
"not enough variable arguments to fit a sentinel"); "not enough variable arguments to fit a sentinel");
return; return;
} }
...@@ -8510,7 +8505,7 @@ check_function_sentinel (const_tree fntype, int nargs, tree *argarray) ...@@ -8510,7 +8505,7 @@ check_function_sentinel (const_tree fntype, int nargs, tree *argarray)
users to cast the NULL they have written there. users to cast the NULL they have written there.
We warn with -Wstrict-null-sentinel, though. */ We warn with -Wstrict-null-sentinel, though. */
&& (warn_strict_null_sentinel || null_node != sentinel)) && (warn_strict_null_sentinel || null_node != sentinel))
warning (OPT_Wformat, "missing sentinel in function call"); warning (OPT_Wformat_, "missing sentinel in function call");
} }
} }
......
...@@ -585,12 +585,6 @@ extern const char *pch_file; ...@@ -585,12 +585,6 @@ extern const char *pch_file;
extern int flag_iso; extern int flag_iso;
/* 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. */ /* C/ObjC language option variables. */
...@@ -732,7 +726,6 @@ extern void check_function_arguments_recurse (void (*) ...@@ -732,7 +726,6 @@ extern void check_function_arguments_recurse (void (*)
unsigned HOST_WIDE_INT); unsigned HOST_WIDE_INT);
extern bool check_builtin_function_arguments (tree, int, tree *); extern bool check_builtin_function_arguments (tree, int, tree *);
extern void check_function_format (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_attribute (tree *, tree, tree, int, bool *);
extern tree handle_format_arg_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 attribute_takes_identifier_p (const_tree);
......
...@@ -358,7 +358,6 @@ c_common_handle_option (size_t scode, const char *arg, int value, ...@@ -358,7 +358,6 @@ c_common_handle_option (size_t scode, const char *arg, int value,
case OPT_Wall: case OPT_Wall:
/* ??? Don't add new options here. Use LangEnabledBy in c.opt. */ /* ??? Don't add new options here. Use LangEnabledBy in c.opt. */
set_Wformat (value);
cpp_opts->warn_trigraphs = value; cpp_opts->warn_trigraphs = value;
cpp_opts->warn_comments = value; cpp_opts->warn_comments = value;
...@@ -385,14 +384,6 @@ c_common_handle_option (size_t scode, const char *arg, int value, ...@@ -385,14 +384,6 @@ c_common_handle_option (size_t scode, const char *arg, int value,
cpp_opts->warn_endif_labels = value; cpp_opts->warn_endif_labels = value;
break; break;
case OPT_Wformat:
set_Wformat (value);
break;
case OPT_Wformat_:
set_Wformat (atoi (arg));
break;
case OPT_Winvalid_pch: case OPT_Winvalid_pch:
cpp_opts->warn_invalid_pch = value; cpp_opts->warn_invalid_pch = value;
break; break;
......
...@@ -381,35 +381,36 @@ C ObjC C++ ObjC++ Var(warn_float_equal) Warning ...@@ -381,35 +381,36 @@ C ObjC C++ ObjC++ Var(warn_float_equal) Warning
Warn if testing floating point numbers for equality Warn if testing floating point numbers for equality
Wformat Wformat
C ObjC C++ ObjC++ Warning C ObjC C++ ObjC++ Warning Alias(Wformat=, 1, 0)
Warn about printf/scanf/strftime/strfmon format string anomalies 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 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 Warn if passing too many arguments to a function for its format string
Wformat-nonliteral 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 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 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 Warn about possible security problems with format functions
Wformat-y2k 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 Warn about strftime formats yielding 2-digit years
Wformat-zero-length 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 Warn about zero-length formats
Wformat= 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 Wignored-qualifiers
C C++ Var(warn_ignored_qualifiers) Warning EnabledBy(Wextra) C C++ Var(warn_ignored_qualifiers) Warning EnabledBy(Wextra)
...@@ -558,9 +559,13 @@ C++ ObjC++ Var(warn_nonvdtor) Warning ...@@ -558,9 +559,13 @@ C++ ObjC++ Var(warn_nonvdtor) Warning
Warn about non-virtual destructors Warn about non-virtual destructors
Wnonnull 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 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= Wnormalized=
C ObjC C++ ObjC++ Joined Warning C ObjC C++ ObjC++ Joined Warning
-Wnormalized=<id|nfc|nfkc> Warn about non-normalised Unicode strings -Wnormalized=<id|nfc|nfkc> Warn about non-normalised Unicode strings
......
...@@ -3241,10 +3241,12 @@ the compiler performs the entire computation with @code{double} ...@@ -3241,10 +3241,12 @@ the compiler performs the entire computation with @code{double}
because the floating-point literal is a @code{double}. because the floating-point literal is a @code{double}.
@item -Wformat @item -Wformat
@itemx -Wformat=@var{n}
@opindex Wformat @opindex Wformat
@opindex Wno-format @opindex Wno-format
@opindex ffreestanding @opindex ffreestanding
@opindex fno-builtin @opindex fno-builtin
@opindex Wformat=
Check calls to @code{printf} and @code{scanf}, etc., to make sure that Check calls to @code{printf} and @code{scanf}, etc., to make sure that
the arguments supplied have types appropriate to the format string the arguments supplied have types appropriate to the format string
specified, and that the conversions specified in the format string make specified, and that the conversions specified in the format string make
...@@ -3268,20 +3270,17 @@ in the selected standard version (but not for @code{strfmon} formats, ...@@ -3268,20 +3270,17 @@ 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 since those are not in any version of the C standard). @xref{C Dialect
Options,,Options Controlling C Dialect}. Options,,Options Controlling C Dialect}.
Since @option{-Wformat} also checks for null format arguments for @table @gcctabopt
several functions, @option{-Wformat} also implies @option{-Wnonnull}. @item -Wformat=1
@itemx -Wformat
@option{-Wformat} is included in @option{-Wall}. For more control over some Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
aspects of format checking, the options @option{-Wformat-y2k}, @option{-Wno-format} is equivalent to @option{-Wformat=0}. Since
@option{-Wno-format-extra-args}, @option{-Wno-format-zero-length}, @option{-Wformat} also checks for null format arguments for several
@option{-Wformat-nonliteral}, @option{-Wformat-security}, and functions, @option{-Wformat} also implies @option{-Wnonnull}. Some
@option{-Wformat=2} are available, but are not included in @option{-Wall}. aspects of this level of format checking can be disabled by the
options: @option{-Wno-format-contains-nul},
@item -Wformat-y2k @option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
@opindex Wformat-y2k @option{-Wformat} is enabled by @option{-Wall}.
@opindex Wno-format-y2k
If @option{-Wformat} is specified, also warn about @code{strftime}
formats that may yield only a two-digit year.
@item -Wno-format-contains-nul @item -Wno-format-contains-nul
@opindex Wno-format-contains-nul @opindex Wno-format-contains-nul
...@@ -3310,6 +3309,12 @@ Unix Specification says that such unused arguments are allowed. ...@@ -3310,6 +3309,12 @@ Unix Specification says that such unused arguments are allowed.
If @option{-Wformat} is specified, do not warn about zero-length formats. If @option{-Wformat} is specified, do not warn about zero-length formats.
The C standard specifies that zero-length formats are allowed. 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 @item -Wformat-nonliteral
@opindex Wformat-nonliteral @opindex Wformat-nonliteral
@opindex Wno-format-nonliteral @opindex Wno-format-nonliteral
...@@ -3330,12 +3335,12 @@ currently a subset of what @option{-Wformat-nonliteral} warns about, but ...@@ -3330,12 +3335,12 @@ currently a subset of what @option{-Wformat-nonliteral} warns about, but
in future warnings may be added to @option{-Wformat-security} that are not in future warnings may be added to @option{-Wformat-security} that are not
included in @option{-Wformat-nonliteral}.) included in @option{-Wformat-nonliteral}.)
@item -Wformat=2 @item -Wformat-y2k
@opindex Wformat=2 @opindex Wformat-y2k
@opindex Wno-format=2 @opindex Wno-format-y2k
Enable @option{-Wformat} plus format checks not included in If @option{-Wformat} is specified, also warn about @code{strftime}
@option{-Wformat}. Currently equivalent to @option{-Wformat formats that may yield only a two-digit year.
-Wformat-nonliteral -Wformat-security -Wformat-y2k}. @end table
@item -Wnonnull @item -Wnonnull
@opindex Wnonnull @opindex Wnonnull
...@@ -3796,7 +3801,6 @@ It is equivalent to @option{-Wstrict-aliasing=3} ...@@ -3796,7 +3801,6 @@ It is equivalent to @option{-Wstrict-aliasing=3}
@item -Wstrict-aliasing=n @item -Wstrict-aliasing=n
@opindex Wstrict-aliasing=n @opindex Wstrict-aliasing=n
@opindex Wno-strict-aliasing=n
This option is only active when @option{-fstrict-aliasing} is active. This option is only active when @option{-fstrict-aliasing} is active.
It warns about code that might break the strict aliasing rules that the It warns about code that might break the strict aliasing rules that the
compiler is using for optimization. compiler is using for optimization.
......
2012-11-07 Manuel López-Ibáñez <manu@gcc.gnu.org> 2012-11-07 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/53063
* gcc.dg/warn-nsstring.c: Use -Wformat explicitly.
2012-11-07 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/51294 PR c/51294
* c-c++-common/pr51294.c: New. * c-c++-common/pr51294.c: New.
......
/* Check that the NSString format extension is rejected in c. */ /* Check that the NSString format extension is rejected in c. */
/* { dg-do compile } */ /* { 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 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" } */ extern void NSLog1 (void *fmt, ...) __attribute__((format(NSString, 1, 2))); /* { dg-warning "is only allowed in Objective-C dialects" } */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment