diff options
author | Marek Polacek <polacek@redhat.com> | 2014-08-10 06:10:49 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2014-08-10 06:10:49 +0000 |
commit | f3bede718836610fd741175f4a1b74ba5717e283 (patch) | |
tree | ad84805c19739010caa9af61cb0d2c384e5aa852 /gcc/c/c-errors.c | |
parent | 7a9f1eed30e169e4d1cfbe4167190db495213406 (diff) | |
download | gcc-f3bede718836610fd741175f4a1b74ba5717e283.zip gcc-f3bede718836610fd741175f4a1b74ba5717e283.tar.gz gcc-f3bede718836610fd741175f4a1b74ba5717e283.tar.bz2 |
re PR c/51849 (-Wc99-compat would be considered useful)
PR c/51849
gcc/
* gcc/doc/invoke.texi: Document -Wc90-c99-compat.
gcc/c-family/
* c-opts.c (sanitize_cpp_opts): Pass warn_c90_c99_compat to libcpp.
* c.opt (Wc90-c99-compat): Add option.
gcc/c/
* c-decl.c (build_array_declarator): Remove check for !flag_isoc99.
Call pedwarn_c90 instead of pedwarn.
(check_bitfield_type_and_width): Likewise.
(declspecs_add_qual): Likewise.
(declspecs_add_type): Likewise.
(warn_variable_length_array): Unify function for -pedantic and -Wvla.
Adjust to only call pedwarn_c90.
(grokdeclarator): Remove pedantic && !flag_isoc99 check. Call
pedwarn_c90 instead of pedwarn.
* c-errors.c (pedwarn_c90): Handle -Wc90-c99-compat.
* c-parser.c (disable_extension_diagnostics): Handle
warn_c90_c99_compat.
(restore_extension_diagnostics): Likewise.
(c_parser_enum_specifier): Remove check for !flag_isoc99. Call
pedwarn_c90 instead of pedwarn.
(c_parser_initelt): Likewise.
(c_parser_postfix_expression): Likewise.
(c_parser_postfix_expression_after_paren_type): Likewise.
(c_parser_compound_statement_nostart): Remove check for !flag_isoc99.
* c-tree.h: Fix formatting.
* c-typeck.c (build_array_ref): Remove check for !flag_isoc99. Call
pedwarn_c90 instead of pedwarn.
gcc/testsuite/
* gcc.dg/Wc90-c99-compat-1.c: New test.
* gcc.dg/Wc90-c99-compat-2.c: New test.
* gcc.dg/Wc90-c99-compat-3.c: New test.
* gcc.dg/Wc90-c99-compat-4.c: New test.
* gcc.dg/Wc90-c99-compat-5.c: New test.
* gcc.dg/Wc90-c99-compat-6.c: New test.
* gcc.dg/wvla-1.c: Adjust dg-warning.
* gcc.dg/wvla-2.c: Adjust dg-warning.
* gcc.dg/wvla-4.c: Adjust dg-warning.
* gcc.dg/wvla-6.c: Adjust dg-warning.
libcpp/
* lex.c (_cpp_lex_direct): Warn when -Wc90-c99-compat is in effect.
* charset.c (_cpp_valid_ucn): Likewise.
* include/cpplib.h (cpp_options): Add cpp_warn_c90_c99_compat.
* macro.c (replace_args): Warn when -Wc90-c99-compat is in effect.
(parse_params): Likewise.
From-SVN: r213786
Diffstat (limited to 'gcc/c/c-errors.c')
-rw-r--r-- | gcc/c/c-errors.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/gcc/c/c-errors.c b/gcc/c/c-errors.c index 92136e7..5a95b88 100644 --- a/gcc/c/c-errors.c +++ b/gcc/c/c-errors.c @@ -44,21 +44,38 @@ pedwarn_c99 (location_t location, int opt, const char *gmsgid, ...) va_end (ap); } -/* Issue an ISO C90 pedantic warning MSGID. This function is supposed to - be used for matters that are allowed in ISO C99 but not supported in - ISO C90, thus we explicitly don't pedwarn when C99 is specified. - (There is no flag_c90.) */ +/* Issue an ISO C90 pedantic warning MSGID if -pedantic outside C99 mode, + otherwise issue warning MSGID if -Wc90-c99-compat is specified, or if + a specific option such as -Wlong-long is specified. + This function is supposed to be used for matters that are allowed in + ISO C99 but not supported in ISO C90, thus we explicitly don't pedwarn + when C99 is specified. (There is no flag_c90.) */ void pedwarn_c90 (location_t location, int opt, const char *gmsgid, ...) { diagnostic_info diagnostic; va_list ap; + bool warned = false; va_start (ap, gmsgid); - diagnostic_set_info (&diagnostic, gmsgid, &ap, location, - flag_isoc99 ? DK_WARNING : DK_PEDWARN); - diagnostic.option_index = opt; - report_diagnostic (&diagnostic); + if (pedantic && !flag_isoc99) + { + diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_PEDWARN); + diagnostic.option_index = opt; + warned = report_diagnostic (&diagnostic); + } + else if (opt != OPT_Wpedantic) + { + diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_WARNING); + diagnostic.option_index = opt; + warned = report_diagnostic (&diagnostic); + } + if (warn_c90_c99_compat && !warned) + { + diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_WARNING); + diagnostic.option_index = OPT_Wc90_c99_compat; + report_diagnostic (&diagnostic); + } va_end (ap); } |