diff options
author | Marek Polacek <polacek@redhat.com> | 2014-08-19 05:34:31 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2014-08-19 05:34:31 +0000 |
commit | 177cce463d56f7a0e1900c59b80307b43b1483d8 (patch) | |
tree | edb34abe06088024ce40380f1b5573f991d29584 /gcc/c/c-errors.c | |
parent | 010ea2883c070de96be645d43874dfd9b4b0a85b (diff) | |
download | gcc-177cce463d56f7a0e1900c59b80307b43b1483d8.zip gcc-177cce463d56f7a0e1900c59b80307b43b1483d8.tar.gz gcc-177cce463d56f7a0e1900c59b80307b43b1483d8.tar.bz2 |
c-opts.c (sanitize_cpp_opts): Make warn_long_long be set according to warn_c90_c99_compat.
gcc/c-family/
* c-opts.c (sanitize_cpp_opts): Make warn_long_long be set according
to warn_c90_c99_compat.
* c.opt (Wc90-c99-compat, Wdeclaration-after-statement): Initialize
to -1.
gcc/c/
* c-decl.c (warn_variable_length_array): Pass OPT_Wvla unconditionally
to pedwarn_c90.
* c-errors.c: Include "opts.h".
(pedwarn_c90): Rewrite to handle -Wno-c90-c99-compat better.
* c-parser.c (disable_extension_diagnostics): Handle negative value
of warn_c90_c99_compat, too.
(restore_extension_diagnostics): Likewise.
(c_parser_compound_statement_nostart): Pass
OPT_Wdeclaration_after_statement unconditionally to pedwarn_c90.
gcc/testsuite/
* gcc.dg/Wc90-c99-compat-4.c: Remove all dg-warnings.
* gcc.dg/Wc90-c99-compat-5.c: Remove all dg-errors.
* gcc.dg/Wc90-c99-compat-7.c: New test.
* gcc.dg/Wc90-c99-compat-8.c: New test.
* gcc.dg/Wdeclaration-after-statement-4.c: New test.
libcpp/
* charset.c (_cpp_valid_ucn): Warn only if -Wc90-c99-compat.
* lex.c (_cpp_lex_direct): Likewise.
* macro.c (replace_args): Likewise.
(parse_params): Likewise.
* include/cpplib.h (cpp_options): Change cpp_warn_c90_c99_compat
to char.
From-SVN: r214131
Diffstat (limited to 'gcc/c/c-errors.c')
-rw-r--r-- | gcc/c/c-errors.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/gcc/c/c-errors.c b/gcc/c/c-errors.c index 5a95b88..89393b9 100644 --- a/gcc/c/c-errors.c +++ b/gcc/c/c-errors.c @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see #include "tm_p.h" #include "flags.h" #include "diagnostic.h" +#include "opts.h" /* Issue an ISO C99 pedantic warning MSGID. */ @@ -56,26 +57,44 @@ pedwarn_c90 (location_t location, int opt, const char *gmsgid, ...) { diagnostic_info diagnostic; va_list ap; - bool warned = false; va_start (ap, gmsgid); - if (pedantic && !flag_isoc99) + /* Warnings such as -Wvla are the most specific ones. */ + if (opt != OPT_Wpedantic) { - diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_PEDWARN); - diagnostic.option_index = opt; - warned = report_diagnostic (&diagnostic); + int opt_var = *(int *) option_flag_var (opt, &global_options); + if (opt_var == 0) + goto out; + else if (opt_var > 0) + { + diagnostic_set_info (&diagnostic, gmsgid, &ap, location, + (pedantic && !flag_isoc99) + ? DK_PEDWARN : DK_WARNING); + diagnostic.option_index = opt; + report_diagnostic (&diagnostic); + goto out; + } } - else if (opt != OPT_Wpedantic) + /* Maybe we want to issue the C90/C99 compat warning, which is more + specific than -pedantic. */ + if (warn_c90_c99_compat > 0) { - diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_WARNING); - diagnostic.option_index = opt; - warned = report_diagnostic (&diagnostic); + diagnostic_set_info (&diagnostic, gmsgid, &ap, location, + (pedantic && !flag_isoc99) + ? DK_PEDWARN : DK_WARNING); + diagnostic.option_index = OPT_Wc90_c99_compat; + report_diagnostic (&diagnostic); } - if (warn_c90_c99_compat && !warned) + /* -Wno-c90-c99-compat suppresses the pedwarns. */ + else if (warn_c90_c99_compat == 0) + ; + /* For -pedantic outside C99, issue a pedwarn. */ + else if (pedantic && !flag_isoc99) { - diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_WARNING); - diagnostic.option_index = OPT_Wc90_c99_compat; + diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_PEDWARN); + diagnostic.option_index = opt; report_diagnostic (&diagnostic); } +out: va_end (ap); } |