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
+2005-05-03 DJ Delorie <dj@redhat.com>
+
+ * 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.
+
2005-05-03 Richard Henderson <rth@redhat.com>
* config/rs6000/rs6000.h (REG_CLASS_CONTENTS): Fix ALL_REGS and
gcc_assert (TREE_CODE (b->decl) != PARM_DECL || !DECL_WEAK (b->decl));
#endif
- if (warn_old_style_definition && !in_system_header)
- warning (0, "%Jold-style function definition", fndecl);
+ if (!in_system_header)
+ warning (OPT_Wold_style_definition, "%Jold-style function definition", fndecl);
/* Match each formal parameter name with its declaration. Save each
decl in the appropriate TREE_PURPOSE slot of the parmids chain. */
/* Warn if this value is an aggregate type,
regardless of which calling convention we are using for it. */
- if (warn_aggregate_return && AGGREGATE_TYPE_P (TREE_TYPE (exp)))
- warning (0, "function call has aggregate value");
+ if (AGGREGATE_TYPE_P (TREE_TYPE (exp)))
+ warning (OPT_Waggregate_return, "function call has aggregate value");
/* If the result of a pure or const function call is ignored (or void),
and none of its arguments are volatile, we can avoid expanding the
Common Joined RejectNegative
-fdiagnostics-show-location=[once|every-line] How often to emit source location at the beginning of line-wrapped diagnostics
+fdiagnostics-show-option
+Common Var(diagnostics_show_options)
+Amend appropriate diagnostic messages with the command line option that controls them.
+
fdump-
Common Joined RejectNegative
-fdump-<type> Dump various compiler internals to a file
#include "diagnostic.h"
#include "langhooks.h"
#include "langhooks-def.h"
+#include "opts.h"
/* Prototypes. */
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
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);
/* 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);
}
location_t location;
/* The kind of diagnostic it is about. */
diagnostic_t kind;
+ /* Which OPT_* directly controls this diagnostic. */
+ int option_index;
} diagnostic_info;
#define pedantic_error_kind() (flag_pedantic_errors ? DK_ERROR : DK_WARNING)
@item Language Independent Options
@xref{Language Independent Options,,Options to Control Diagnostic Messages Formatting}.
@gccoptlist{-fmessage-length=@var{n} @gol
--fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}}
+-fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}} @gol
+-fdiagnostics-show-options
@item Warning Options
@xref{Warning Options,,Options to Request or Suppress Warnings}.
prefix) for physical lines that result from the process of breaking
a message which is too long to fit on a single line.
+@item -fdiagnostics-show-options
+@opindex fdiagnostics-show-options
+This option instructs the diagnostic machinery to add text to each
+diagnostic emitted, which indicates which command line option directly
+controls that diagnostic, when such an option is known to the
+diagnostic machinery.
+
@end table
@node Warning Options
/* Warn if this value is an aggregate type,
regardless of which calling convention we are using for it. */
- if (warn_aggregate_return
- && AGGREGATE_TYPE_P (TREE_TYPE (DECL_RESULT (subr))))
- warning (0, "function returns an aggregate");
+ if (AGGREGATE_TYPE_P (TREE_TYPE (DECL_RESULT (subr))))
+ warning (OPT_Waggregate_return, "function returns an aggregate");
}
/* Make sure all values used by the optimization passes have sane
a simple on-off switch. */
int
-option_enabled (const struct cl_option *option)
+option_enabled (int opt_idx)
{
+ const struct cl_option *option = &(cl_options[opt_idx]);
if (option->flag_var)
switch (option->var_cond)
{
extern unsigned num_in_fnames;
extern void decode_options (unsigned int argc, const char **argv);
-extern int option_enabled (const struct cl_option *);
+extern int option_enabled (int opt_idx);
extern void print_filtered_help (unsigned int);
#endif
for (j = 0; j < cl_options_count; j++)
if ((cl_options[j].flags & CL_REPORT)
- && option_enabled (&cl_options[j]) > 0)
+ && option_enabled (j) > 0)
pos = print_single_switch (file, pos, max, indent, sep, term,
"", cl_options[j].opt_text);