diff options
author | dj <dj@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-05-03 17:55:46 +0000 |
---|---|---|
committer | dj <dj@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-05-03 17:55:46 +0000 |
commit | efb9d9ee8e1478917ccbfa1e47447d8dfb63953c (patch) | |
tree | cff3402fafefe694afbb81cbc70f93161517f19e /gcc/diagnostic.c | |
parent | a869d17ed1730aabcda5c3733c3518267ba19628 (diff) | |
download | ppe42-gcc-efb9d9ee8e1478917ccbfa1e47447d8dfb63953c.tar.gz ppe42-gcc-efb9d9ee8e1478917ccbfa1e47447d8dfb63953c.zip |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@99169 138bc75d-0d04-0410-961f-82ee72b054a4
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 941ddb811f7..b50fb1410c4 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); } |