diff options
author | Marek Polacek <polacek@redhat.com> | 2014-08-19 06:04:38 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2014-08-19 06:04:38 +0000 |
commit | 35aff4fb82ce0f615dc5e0ad73341a1fe77cbd12 (patch) | |
tree | 252dbb8b85e09aa8d379abb28ffc5e483fa4edb2 /gcc/c/c-errors.c | |
parent | fdec323d35ab9bf489e374c0545621bc90dd08c0 (diff) | |
download | gcc-35aff4fb82ce0f615dc5e0ad73341a1fe77cbd12.zip gcc-35aff4fb82ce0f615dc5e0ad73341a1fe77cbd12.tar.gz gcc-35aff4fb82ce0f615dc5e0ad73341a1fe77cbd12.tar.bz2 |
invoke.texi: Document -Wc99-c11-compat.
* doc/invoke.texi: Document -Wc99-c11-compat.
c-family/
* c.opt (Wc99-c11-compat): New option.
c/
* c-decl.c (diagnose_mismatched_decls): Unconditionally call
pedwarn_c99 instead of pedwarn.
(grokfield): Likewise.
(warn_defaults_to): New function.
(grokdeclarator): Call warn_defaults_to instead of pedwarn_c99.
Unconditionally call pedwarn_c99 instead of pedwarn.
(start_function): Call warn_defaults_to instead of pedwarn_c99.
(declspecs_add_scspec): Call pedwarn_c99 instead of pedwarn, don't
check flag_isoc11 before.
* c-errors.c (pedwarn_c99): Change the return type to bool.
Handle -Wc99-c11-compat.
* c-parser.c (disable_extension_diagnostics): Handle
warn_c99_c11_compat.
(restore_extension_diagnostics): Likewise.
(c_parser_static_assert_declaration_no_semi): Call pedwarn_c99
instead of pedwarn, don't check flag_isoc11 before.
(c_parser_declspecs): Likewise.
(c_parser_alignas_specifier): Likewise.
(c_parser_alignof_expression): Likewise.
(c_parser_generic_selection): Likewise.
* c-tree.h (pedwarn_c99): Update declaration.
* c-typeck.c (c_finish_return): Call pedwarn or warning_at instead
of pedwarn_c99.
testsuite/
* gcc.dg/Wc99-c11-compat-1.c: New test.
* gcc.dg/Wc99-c11-compat-2.c: New test.
* gcc.dg/Wc99-c11-compat-3.c: New test.
* gcc.dg/Wc99-c11-compat-4.c: New test.
* gcc.dg/Wc99-c11-compat-5.c: New test.
* gcc.dg/Wc99-c11-compat-6.c: New test.
* gcc.dg/Wc99-c11-compat-7.c: New test.
From-SVN: r214133
Diffstat (limited to 'gcc/c/c-errors.c')
-rw-r--r-- | gcc/c/c-errors.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/gcc/c/c-errors.c b/gcc/c/c-errors.c index 89393b9..c1f9c35 100644 --- a/gcc/c/c-errors.c +++ b/gcc/c/c-errors.c @@ -29,20 +29,42 @@ along with GCC; see the file COPYING3. If not see #include "diagnostic.h" #include "opts.h" -/* Issue an ISO C99 pedantic warning MSGID. */ +/* Issue an ISO C99 pedantic warning MSGID if -pedantic outside C11 mode, + otherwise issue warning MSGID if -Wc99-c11-compat is specified. + This function is supposed to be used for matters that are allowed in + ISO C11 but not supported in ISO C99, thus we explicitly don't pedwarn + when C11 is specified. */ -void +bool pedwarn_c99 (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_PEDWARN : DK_WARNING); - diagnostic.option_index = opt; - report_diagnostic (&diagnostic); + /* If desired, issue the C99/C11 compat warning, which is more specific + than -pedantic. */ + if (warn_c99_c11_compat > 0) + { + diagnostic_set_info (&diagnostic, gmsgid, &ap, location, + (pedantic && !flag_isoc11) + ? DK_PEDWARN : DK_WARNING); + diagnostic.option_index = OPT_Wc99_c11_compat; + warned = report_diagnostic (&diagnostic); + } + /* -Wno-c99-c11-compat suppresses even the pedwarns. */ + else if (warn_c99_c11_compat == 0) + ; + /* For -pedantic outside C11, issue a pedwarn. */ + else if (pedantic && !flag_isoc11) + { + diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_PEDWARN); + diagnostic.option_index = opt; + warned = report_diagnostic (&diagnostic); + } va_end (ap); + return warned; } /* Issue an ISO C90 pedantic warning MSGID if -pedantic outside C99 mode, |