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
This commit is contained in:
parent
6ceec5933a
commit
ccf08a6ed7
|
@ -1,3 +1,24 @@
|
|||
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
|
||||
|
|
|
@ -6011,8 +6011,8 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
|
|||
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. */
|
||||
|
|
|
@ -1934,8 +1934,8 @@ expand_call (tree exp, rtx target, int ignore)
|
|||
|
||||
/* 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
|
||||
|
|
|
@ -336,6 +336,10 @@ fdiagnostics-show-location=
|
|||
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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ typedef struct
|
|||
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)
|
||||
|
|
|
@ -206,7 +206,8 @@ Objective-C and Objective-C++ Dialects}.
|
|||
@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}.
|
||||
|
@ -2090,6 +2091,13 @@ messages reporter to emit the same source location information (as
|
|||
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
|
||||
|
|
|
@ -3850,9 +3850,8 @@ init_function_start (tree subr)
|
|||
|
||||
/* 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
|
||||
|
|
|
@ -1400,8 +1400,9 @@ wrap_help (const char *help, const char *item, unsigned int item_width)
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -71,7 +71,7 @@ extern const char **in_fnames;
|
|||
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
|
||||
|
|
|
@ -1360,7 +1360,7 @@ print_switch_values (FILE *file, int pos, int max,
|
|||
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue