aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog21
-rw-r--r--gcc/c-decl.c4
-rw-r--r--gcc/calls.c4
-rw-r--r--gcc/common.opt4
-rw-r--r--gcc/diagnostic.c14
-rw-r--r--gcc/diagnostic.h2
-rw-r--r--gcc/doc/invoke.texi10
-rw-r--r--gcc/function.c5
-rw-r--r--gcc/opts.c3
-rw-r--r--gcc/opts.h2
-rw-r--r--gcc/toplev.c2
11 files changed, 59 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3b64a1b..941c6a7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index c8516c7..e7ac0d3 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -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. */
diff --git a/gcc/calls.c b/gcc/calls.c
index 2739832..b26e873 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -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
diff --git a/gcc/common.opt b/gcc/common.opt
index b75785c..466077c 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -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
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);
}
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index a9fe623..37cded711 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -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)
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 2bb8744..2de05a8 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -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
diff --git a/gcc/function.c b/gcc/function.c
index 2b551e4..065c124 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -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
diff --git a/gcc/opts.c b/gcc/opts.c
index 5c09450..4311f4c 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -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)
{
diff --git a/gcc/opts.h b/gcc/opts.h
index b6f1572..bed419e 100644
--- a/gcc/opts.h
+++ b/gcc/opts.h
@@ -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
diff --git a/gcc/toplev.c b/gcc/toplev.c
index c7e5440..9f1bb79 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -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);