diff options
author | DJ Delorie <dj@redhat.com> | 2005-05-03 13:55:46 -0400 |
---|---|---|
committer | DJ Delorie <dj@gcc.gnu.org> | 2005-05-03 13:55:46 -0400 |
commit | ccf08a6ed7ade866dab79e1c0dc853bae887f9e2 (patch) | |
tree | cff3402fafefe694afbb81cbc70f93161517f19e /gcc/diagnostic.c | |
parent | 6ceec5933a1159c7b5595047ee435343f58ed038 (diff) | |
download | gcc-ccf08a6ed7ade866dab79e1c0dc853bae887f9e2.zip gcc-ccf08a6ed7ade866dab79e1c0dc853bae887f9e2.tar.gz gcc-ccf08a6ed7ade866dab79e1c0dc853bae887f9e2.tar.bz2 |
c-decl.c (store_parm_decls_oldstyle): Let diagnostic machinery decide if the warning will be printed.
* c-decl.c (store_parm_decls_oldstyle): Let diagnostic machinery
decide if the warning will be printed.
* calls.c (expand_call): Likewise.
* function.c (init-function_start): Likewise.
* common.opt (-fdiagnostics-show-option): New.
* opts.c (option_enabled): Accept the option index instead of a
pointer to the option descriptor.
* opts.h (option_enabled): Likewise.
* toplev.c (print_switch_values): Pass option index, not option
descriptor.
* diagnostic.h (diagnostic_info): Add option_index.
* diagnostic.c: Include opts.h.
(diagnostic_set_info): Initialize option_index.
(diagnostic_report_diagnostic): Amend option name if appropriate.
(warning): Check to see if the specified warning is enabled.
Store option index.
* doc/invoke.texi (-fdiagnostics-show-options): Document.
From-SVN: r99169
Diffstat (limited to 'gcc/diagnostic.c')
-rw-r--r-- | gcc/diagnostic.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 941ddb8..b50fb14 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -40,6 +40,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "diagnostic.h" #include "langhooks.h" #include "langhooks-def.h" +#include "opts.h" /* Prototypes. */ @@ -120,6 +121,7 @@ diagnostic_set_info (diagnostic_info *diagnostic, const char *msgid, diagnostic->message.format_spec = _(msgid); diagnostic->location = location; diagnostic->kind = kind; + diagnostic->option_index = 0; } /* Return a malloc'd string describing a location. The caller is @@ -333,6 +335,11 @@ diagnostic_report_diagnostic (diagnostic_context *context, if (diagnostic_count_diagnostic (context, diagnostic)) { + if (diagnostics_show_options && diagnostic->option_index) + diagnostic->message.format_spec + = ACONCAT ((diagnostic->message.format_spec, + " [", cl_options[diagnostic->option_index].opt_text, "]", NULL)); + pp_prepare_to_format (context->printer, &diagnostic->message, &diagnostic->location); (*diagnostic_starter (context)) (context, diagnostic); @@ -412,13 +419,18 @@ inform (const char *msgid, ...) /* A warning. Use this for code which is correct according to the relevant language specification but is likely to be buggy anyway. */ void -warning (int opt ATTRIBUTE_UNUSED, const char *msgid, ...) +warning (int opt, const char *msgid, ...) { diagnostic_info diagnostic; va_list ap; + if (opt && ! option_enabled (opt)) + return; + va_start (ap, msgid); diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_WARNING); + diagnostic.option_index = opt; + report_diagnostic (&diagnostic); va_end (ap); } |