diff options
author | Geoffrey Keating <geoffk@redhat.com> | 2002-03-05 02:34:07 +0000 |
---|---|---|
committer | Geoffrey Keating <geoffk@gcc.gnu.org> | 2002-03-05 02:34:07 +0000 |
commit | 75227a33f7f789bca5090099a279b5b8d63d571c (patch) | |
tree | 6806586cc8e5784a42c5d33e4ef34100e6e7b370 | |
parent | 4f1aac426685bb179bd45b525ae95e1f80bd5149 (diff) | |
download | gcc-75227a33f7f789bca5090099a279b5b8d63d571c.zip gcc-75227a33f7f789bca5090099a279b5b8d63d571c.tar.gz gcc-75227a33f7f789bca5090099a279b5b8d63d571c.tar.bz2 |
toplev.c (documented_lang_options): Document more language-specific options.
* toplev.c (documented_lang_options): Document more
language-specific options.
* doc/invoke.texi (Warning Options): Correct documentation for
-Wno-multichar, -Wno-div-by-zero, and -Wsystem-headers.
* c-decl.c (c_decode_option): Use a table to handle warning options.
From-SVN: r50299
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/c-decl.c | 207 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 60 | ||||
-rw-r--r-- | gcc/toplev.c | 31 |
4 files changed, 119 insertions, 187 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7db049b..dee45a2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2002-03-04 Geoffrey Keating <geoffk@redhat.com> + + * toplev.c (documented_lang_options): Document more + language-specific options. + * doc/invoke.texi (Warning Options): Correct documentation for + -Wno-multichar, -Wno-div-by-zero, and -Wsystem-headers. + * c-decl.c (c_decode_option): Use a table to handle warning options. + 2002-03-05 Hans-Peter Nilsson <hp@bitrange.com> * config/mmix/mmix.h (ENCODE_SECTION_INFO): Pass on new second diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 845cefb..d15f47e 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -460,6 +460,50 @@ c_decode_option (argc, argv) int strings_processed; char *p = argv[0]; + static const struct { + /* The name of the option. */ + const char *option; + /* If non-NULL, a flag variable to set to 0 or 1. If NULL, + this means that cpp handles this option. */ + int *flag; + } warn_options[] = { + /* This list is in alphabetical order. Keep it like that. */ + { "bad-function-cast", &warn_bad_function_cast }, + { "cast-qual", &warn_cast_qual }, + { "char-subscripts", &warn_char_subscripts }, + { "comment", NULL }, + { "comments", NULL }, + { "conversion", &warn_conversion }, + { "div-by-zero", &warn_div_by_zero }, + { "float-equal", &warn_float_equal }, + { "format-extra-args", &warn_format_extra_args }, + { "format-nonliteral", &warn_format_nonliteral }, + { "format-security", &warn_format_security }, + { "format-y2k", &warn_format_y2k }, + { "implicit-function-declaration", &mesg_implicit_function_declaration }, + { "implicit-int", &warn_implicit_int }, + { "import", NULL }, + { "long-long", &warn_long_long }, + { "main", &warn_main }, + { "missing-braces", &warn_missing_braces }, + { "missing-declarations", &warn_missing_declarations }, + { "missing-format-attribute", &warn_missing_format_attribute }, + { "missing-prototypes", &warn_missing_prototypes }, + { "multichar", &warn_multichar }, + { "nested-externs", &warn_nested_externs }, + { "parentheses", &warn_parentheses }, + { "pointer-arith", &warn_pointer_arith }, + { "redundant-decls", &warn_redundant_decls }, + { "return-type", &warn_return_type }, + { "sequence-point", &warn_sequence_point }, + { "sign-compare", &warn_sign_compare }, + { "strict-prototypes", &warn_strict_prototypes }, + { "traditional", &warn_traditional }, + { "trigraphs", NULL }, + { "undef", NULL }, + { "write-strings", &flag_const_strings } + }; + strings_processed = cpp_handle_option (parse_in, argc, argv, 0); if (!strcmp (p, "-fhosted") || !strcmp (p, "-fno-freestanding")) @@ -595,14 +639,12 @@ c_decode_option (argc, argv) goto iso_1990; else if (!strcmp (p, "-Werror-implicit-function-declaration")) mesg_implicit_function_declaration = 2; - else if (!strcmp (p, "-Wimplicit-function-declaration")) - mesg_implicit_function_declaration = 1; - else if (!strcmp (p, "-Wno-implicit-function-declaration")) - mesg_implicit_function_declaration = 0; - else if (!strcmp (p, "-Wimplicit-int")) - warn_implicit_int = 1; - else if (!strcmp (p, "-Wno-implicit-int")) - warn_implicit_int = 0; + else if (!strncmp (p, "-Wformat=", 9)) + set_Wformat (atoi (p + 9)); + else if (!strcmp (p, "-Wformat")) + set_Wformat (1); + else if (!strcmp (p, "-Wno-format")) + set_Wformat (0); else if (!strcmp (p, "-Wimplicit")) { warn_implicit_int = 1; @@ -611,142 +653,8 @@ c_decode_option (argc, argv) } else if (!strcmp (p, "-Wno-implicit")) warn_implicit_int = 0, mesg_implicit_function_declaration = 0; - else if (!strcmp (p, "-Wlong-long")) - warn_long_long = 1; - else if (!strcmp (p, "-Wno-long-long")) - warn_long_long = 0; - else if (!strcmp (p, "-Wwrite-strings")) - flag_const_strings = 1; - else if (!strcmp (p, "-Wno-write-strings")) - flag_const_strings = 0; - else if (!strcmp (p, "-Wcast-qual")) - warn_cast_qual = 1; - else if (!strcmp (p, "-Wno-cast-qual")) - warn_cast_qual = 0; - else if (!strcmp (p, "-Wbad-function-cast")) - warn_bad_function_cast = 1; - else if (!strcmp (p, "-Wno-bad-function-cast")) - warn_bad_function_cast = 0; - else if (!strcmp (p, "-Wno-missing-noreturn")) - warn_missing_noreturn = 0; - else if (!strcmp (p, "-Wmissing-format-attribute")) - warn_missing_format_attribute = 1; - else if (!strcmp (p, "-Wno-missing-format-attribute")) - warn_missing_format_attribute = 0; - else if (!strcmp (p, "-Wpointer-arith")) - warn_pointer_arith = 1; - else if (!strcmp (p, "-Wno-pointer-arith")) - warn_pointer_arith = 0; - else if (!strcmp (p, "-Wstrict-prototypes")) - warn_strict_prototypes = 1; - else if (!strcmp (p, "-Wno-strict-prototypes")) - warn_strict_prototypes = 0; - else if (!strcmp (p, "-Wmissing-prototypes")) - warn_missing_prototypes = 1; - else if (!strcmp (p, "-Wno-missing-prototypes")) - warn_missing_prototypes = 0; - else if (!strcmp (p, "-Wmissing-declarations")) - warn_missing_declarations = 1; - else if (!strcmp (p, "-Wno-missing-declarations")) - warn_missing_declarations = 0; - else if (!strcmp (p, "-Wredundant-decls")) - warn_redundant_decls = 1; - else if (!strcmp (p, "-Wno-redundant-decls")) - warn_redundant_decls = 0; - else if (!strcmp (p, "-Wnested-externs")) - warn_nested_externs = 1; - else if (!strcmp (p, "-Wno-nested-externs")) - warn_nested_externs = 0; - else if (!strcmp (p, "-Wtraditional")) - warn_traditional = 1; - else if (!strcmp (p, "-Wno-traditional")) - warn_traditional = 0; - else if (!strncmp (p, "-Wformat=", 9)) - set_Wformat (atoi (p + 9)); - else if (!strcmp (p, "-Wformat")) - set_Wformat (1); - else if (!strcmp (p, "-Wno-format")) - 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, "-Wformat-security")) - warn_format_security = 1; - else if (!strcmp (p, "-Wno-format-security")) - warn_format_security = 0; - else if (!strcmp (p, "-Wchar-subscripts")) - warn_char_subscripts = 1; - else if (!strcmp (p, "-Wno-char-subscripts")) - warn_char_subscripts = 0; - else if (!strcmp (p, "-Wconversion")) - warn_conversion = 1; - else if (!strcmp (p, "-Wno-conversion")) - warn_conversion = 0; - else if (!strcmp (p, "-Wparentheses")) - warn_parentheses = 1; - else if (!strcmp (p, "-Wno-parentheses")) - warn_parentheses = 0; - else if (!strcmp (p, "-Wreturn-type")) - warn_return_type = 1; - else if (!strcmp (p, "-Wno-return-type")) - warn_return_type = 0; - else if (!strcmp (p, "-Wsequence-point")) - warn_sequence_point = 1; - else if (!strcmp (p, "-Wno-sequence-point")) - warn_sequence_point = 0; - else if (!strcmp (p, "-Wcomment")) - ; /* cpp handles this one. */ - else if (!strcmp (p, "-Wno-comment")) - ; /* cpp handles this one. */ - else if (!strcmp (p, "-Wcomments")) - ; /* cpp handles this one. */ - else if (!strcmp (p, "-Wno-comments")) - ; /* cpp handles this one. */ - else if (!strcmp (p, "-Wtrigraphs")) - ; /* cpp handles this one. */ - else if (!strcmp (p, "-Wno-trigraphs")) - ; /* cpp handles this one. */ - else if (!strcmp (p, "-Wundef")) - ; /* cpp handles this one. */ - else if (!strcmp (p, "-Wno-undef")) - ; /* cpp handles this one. */ - else if (!strcmp (p, "-Wimport")) - ; /* cpp handles this one. */ - else if (!strcmp (p, "-Wno-import")) - ; /* cpp handles this one. */ - else if (!strcmp (p, "-Wmissing-braces")) - warn_missing_braces = 1; - else if (!strcmp (p, "-Wno-missing-braces")) - warn_missing_braces = 0; - else if (!strcmp (p, "-Wmain")) - warn_main = 1; else if (!strcmp (p, "-Wno-main")) warn_main = -1; - else if (!strcmp (p, "-Wsign-compare")) - warn_sign_compare = 1; - else if (!strcmp (p, "-Wno-sign-compare")) - warn_sign_compare = 0; - else if (!strcmp (p, "-Wfloat-equal")) - warn_float_equal = 1; - else if (!strcmp (p, "-Wno-float-equal")) - warn_float_equal = 0; - else if (!strcmp (p, "-Wmultichar")) - warn_multichar = 1; - else if (!strcmp (p, "-Wno-multichar")) - warn_multichar = 0; - else if (!strcmp (p, "-Wdiv-by-zero")) - warn_div_by_zero = 1; - else if (!strcmp (p, "-Wno-div-by-zero")) - warn_div_by_zero = 0; else if (!strcmp (p, "-Wunknown-pragmas")) /* Set to greater than 1, so that even unknown pragmas in system headers will be warned about. */ @@ -777,7 +685,20 @@ c_decode_option (argc, argv) warn_unknown_pragmas = 1; } else - return strings_processed; + { + size_t i; + for (i = 0; i < sizeof (warn_options) / sizeof (warn_options[0]); i++) + if (strncmp (p, "-W", 2) == 0 + && warn_options[i].flag + && (strcmp (p+2, warn_options[i].option) == 0 + || (strncmp (p+2, "no-", 3) == 0 + && strcmp (p+5, warn_options[i].option) == 0))) + { + *(warn_options[i].flag) = strncmp (p+2, "no-", 3) != 0; + return 1; + } + return strings_processed; + } return 1; } diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index e3bca52..a6d37e2 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -214,7 +214,7 @@ in the following sections. -w -W -Wall -Waggregate-return @gol -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol -Wconversion -Wno-deprecated-declarations @gol --Wdisabled-optimization -Wdiv-by-zero -Werror @gol +-Wdisabled-optimization -Wno-div-by-zero -Werror @gol -Wfloat-equal -Wformat -Wformat=2 @gol -Wformat-nonliteral -Wformat-security @gol -Wimplicit -Wimplicit-int @gol @@ -224,7 +224,7 @@ in the following sections. -Wlarger-than-@var{len} -Wlong-long @gol -Wmain -Wmissing-braces -Wmissing-declarations @gol -Wmissing-format-attribute -Wmissing-noreturn @gol --Wmultichar -Wno-format-extra-args -Wno-format-y2k @gol +-Wno-multichar -Wno-format-extra-args -Wno-format-y2k @gol -Wno-import -Wpacked -Wpadded @gol -Wparentheses -Wpointer-arith -Wredundant-decls @gol -Wreturn-type -Wsequence-point -Wshadow @gol @@ -2172,35 +2172,6 @@ All of the above @samp{-W} options combined. This enables all the warnings about constructions that some users consider questionable, and that are easy to avoid (or modify to prevent the warning), even in conjunction with macros. - -@item -Wdiv-by-zero -@opindex Wno-div-by-zero -@opindex Wdiv-by-zero -Warn about compile-time integer division by zero. This is default. To -inhibit the warning messages, use @option{-Wno-div-by-zero}. Floating -point division by zero is not warned about, as it can be a legitimate -way of obtaining infinities and NaNs. - -@item -Wmultichar -@opindex Wno-multichar -@opindex Wmultichar -Warn if a multicharacter constant (@samp{'FOOF'}) is used. This is -default. To inhibit the warning messages, use @option{-Wno-multichar}. -Usually they indicate a typo in the user's code, as they have -implementation-defined values, and should not be used in portable code. - -@item -Wsystem-headers -@opindex Wsystem-headers -@cindex warnings from system headers -@cindex system headers, warnings from -Print warning messages for constructs found in system header files. -Warnings from system headers are normally suppressed, on the assumption -that they usually do not indicate real problems and would only make the -compiler output harder to read. Using this command line option tells -GCC to emit warnings from system headers as if they occurred in user -code. However, note that using @option{-Wall} in conjunction with this -option will @emph{not} warn about unknown pragmas in system -headers---for that, @option{-Wunknown-pragmas} must also be used. @end table The following @option{-W@dots{}} options are not implied by @option{-Wall}. @@ -2289,6 +2260,26 @@ struct s x = @{ 3, 4 @}; @end smallexample @end itemize +@item -Wno-div-by-zero +@opindex Wno-div-by-zero +@opindex Wdiv-by-zero +Do not warn about compile-time integer division by zero. Floating point +division by zero is not warned about, as it can be a legitimate way of +obtaining infinities and NaNs. + +@item -Wsystem-headers +@opindex Wsystem-headers +@cindex warnings from system headers +@cindex system headers, warnings from +Print warning messages for constructs found in system header files. +Warnings from system headers are normally suppressed, on the assumption +that they usually do not indicate real problems and would only make the +compiler output harder to read. Using this command line option tells +GCC to emit warnings from system headers as if they occurred in user +code. However, note that using @option{-Wall} in conjunction with this +option will @emph{not} warn about unknown pragmas in system +headers---for that, @option{-Wunknown-pragmas} must also be used. + @item -Wfloat-equal @opindex Wfloat-equal Warn if floating point values are used in equality comparisons. @@ -2505,6 +2496,13 @@ case, and some functions for which @code{format} attributes are appropriate may not be detected. This option has no effect unless @option{-Wformat} is enabled (possibly by @option{-Wall}). +@item -Wno-multichar +@opindex Wno-multichar +@opindex Wmultichar +Do not warn if a multicharacter constant (@samp{'FOOF'}) is used. +Usually they indicate a typo in the user's code, as they have +implementation-defined values, and should not be used in portable code. + @item -Wno-deprecated-declarations @opindex Wno-deprecated-declarations Do not warn about uses of functions, variables, and types marked as diff --git a/gcc/toplev.c b/gcc/toplev.c index 9ff37c3..93cb2c9 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1231,7 +1231,6 @@ documented_lang_options[] = { "-Wbad-function-cast", N_("Warn about casting functions to incompatible types") }, { "-Wno-bad-function-cast", "" }, - { "-Wno-missing-noreturn", "" }, { "-Wmissing-format-attribute", N_("Warn about functions which might be candidates for format attributes") }, { "-Wno-missing-format-attribute", "" }, @@ -1250,12 +1249,15 @@ documented_lang_options[] = { "-Wconversion", N_("Warn about possibly confusing type conversions") }, { "-Wno-conversion", "" }, + { "-Wdiv-by-zero", "" }, + { "-Wno-div-by-zero", + N_("Do not warn about compile-time integer division by zero") }, + { "-Wfloat-equal", + N_("Warn about testing equality of floating point numbers") }, + { "-Wno-float-equal", "" }, { "-Wformat", N_("Warn about printf/scanf/strftime/strfmon format anomalies") }, { "-Wno-format", "" }, - { "-Wformat-y2k", "" }, - { "-Wno-format-y2k", - N_("Don't warn about strftime formats yielding 2 digit years") }, { "-Wformat-extra-args", "" }, { "-Wno-format-extra-args", N_("Don't warn about too many arguments to format functions") }, @@ -1265,6 +1267,9 @@ documented_lang_options[] = { "-Wformat-security", N_("Warn about possible security problems with format functions") }, { "-Wno-format-security", "" }, + { "-Wformat-y2k", "" }, + { "-Wno-format-y2k", + N_("Don't warn about strftime formats yielding 2 digit years") }, { "-Wimplicit-function-declaration", N_("Warn about implicit function declarations") }, { "-Wno-implicit-function-declaration", "" }, @@ -1301,24 +1306,21 @@ documented_lang_options[] = { "-Wparentheses", N_("Warn about possible missing parentheses") }, { "-Wno-parentheses", "" }, - { "-Wsequence-point", - N_("Warn about possible violations of sequence point rules") }, - { "-Wno-sequence-point", "" }, { "-Wpointer-arith", N_("Warn about function pointer arithmetic") }, { "-Wno-pointer-arith", "" }, { "-Wredundant-decls", N_("Warn about multiple declarations of the same object") }, { "-Wno-redundant-decls", "" }, + { "-Wreturn-type", + N_("Warn whenever a function's return-type defaults to int") }, + { "-Wno-return-type", "" }, + { "-Wsequence-point", + N_("Warn about possible violations of sequence point rules") }, + { "-Wno-sequence-point", "" }, { "-Wsign-compare", N_("Warn about signed/unsigned comparisons") }, { "-Wno-sign-compare", "" }, - { "-Wfloat-equal", - N_("Warn about testing equality of floating point numbers") }, - { "-Wno-float-equal", "" }, - { "-Wunknown-pragmas", - N_("Warn about unrecognized pragmas") }, - { "-Wno-unknown-pragmas", "" }, { "-Wstrict-prototypes", N_("Warn about non-prototyped function decls") }, { "-Wno-strict-prototypes", "" }, @@ -1330,6 +1332,9 @@ documented_lang_options[] = { "-Wno-trigraphs", "" }, { "-Wundef", "" }, { "-Wno-undef", "" }, + { "-Wunknown-pragmas", + N_("Warn about unrecognized pragmas") }, + { "-Wno-unknown-pragmas", "" }, { "-Wwrite-strings", N_("Mark strings as 'const char *'") }, { "-Wno-write-strings", "" }, |