summaryrefslogtreecommitdiff
path: root/gcc/diagnostic.h
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-05-26 13:40:53 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-05-26 13:40:53 +0000
commit3c6a9715a98d0ee9da8bf24324d0a8a4bba990f0 (patch)
treecb4cbcf522a027e78291661bf1d98cb25d1f7585 /gcc/diagnostic.h
parentabdd77b808b58f43030d78aa8ce6ef62d4b8bbbd (diff)
downloadgcc-3c6a9715a98d0ee9da8bf24324d0a8a4bba990f0.tar.gz
* diagnostic.c: Don't include opts.h.
(permissive_error_option): Define. (diagnostic_initialize): Take n_opts parameter. Allocate memory for classify_diagnostic. Don't use memset for classify_diagnostic. Initialize new and recently added fields. (diagnostic_classify_diagnostic): Use context->n_opts instead of N_OPTS. (diagnostic_report_diagnostic): Pass context parameter to diagnostic_report_warnings_p. Use option_enabled and option_name hooks from context. (emit_diagnostic): Use permissive_error_option. (permerror): Likewise. * diagnostic.h: Don't include options.h. (struct diagnostic_context): Add n_opts, opt_permissive, inhibit_warnings, warn_system_headers, option_enabled and option_name fields. Change classify_diagnostic to a pointer. * opts-diagnostic.h: New file. * opts.c: Include opts-diagnostic.h. (common_handle_option): Set global_dc fields for -Wfatal-errors, -Wsystem-headers, -fshow-column, -pedantic-errors and -w. (option_name): New function. * c-opts.c (c_common_init_options): Set global_dc->opt_permissive. (c_common_handle_option): Set global_dc->permissive for -fpermissive. * c-common.c (c_cpp_error): Save and restore global_dc->warn_system_headers, not variable warn_system_headers. * toplev.c: Include opts-diagnostic.h. (general_init): Update call to diagnostic_initialize. Set global_dc->show_column, global_dc->option_enabled and global_dc->option_name. (process_options): Don't set global_dc fields here. * Makefile.in (DIAGNOSTIC_H): Remove options.h. (diagnostic.o, opts.o, toplev.o): Update dependencies. fortran: * cpp.c (cb_cpp_error): Save and restore global_dc->warn_system_headers, not variable warn_system_headers. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159869 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/diagnostic.h')
-rw-r--r--gcc/diagnostic.h48
1 files changed, 37 insertions, 11 deletions
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index 9fd508b78ff..7aa053188d4 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -23,7 +23,6 @@ along with GCC; see the file COPYING3. If not see
#define GCC_DIAGNOSTIC_H
#include "pretty-print.h"
-#include "options.h"
/* Constants used to discriminate diagnostics. */
typedef enum
@@ -73,12 +72,17 @@ struct diagnostic_context
/* True if it has been requested that warnings be treated as errors. */
bool warning_as_error_requested;
- /* For each option index that can be passed to warning() et all
- (OPT_* from options.h), this array may contain a new kind that
- the diagnostic should be changed to before reporting, or
- DK_UNSPECIFIED to leave it as the reported kind, or DK_IGNORED to
- not report it at all. N_OPTS is from <options.h>. */
- diagnostic_t classify_diagnostic[N_OPTS];
+ /* The number of option indexes that can be passed to warning() et
+ al. */
+ int n_opts;
+
+ /* For each option index that can be passed to warning() et al
+ (OPT_* from options.h when using this code with the core GCC
+ options), this array may contain a new kind that the diagnostic
+ should be changed to before reporting, or DK_UNSPECIFIED to leave
+ it as the reported kind, or DK_IGNORED to not report it at
+ all. */
+ diagnostic_t *classify_diagnostic;
/* True if we should print the command line option which controls
each diagnostic, if known. */
@@ -96,9 +100,19 @@ struct diagnostic_context
/* True if permerrors are warnings. */
bool permissive;
+ /* The index of the option to associate with turning permerrors into
+ warnings. */
+ int opt_permissive;
+
/* True if errors are fatal. */
bool fatal_errors;
+ /* True if all warnings should be disabled. */
+ bool inhibit_warnings;
+
+ /* True if warnings should be given in system headers. */
+ bool warn_system_headers;
+
/* This function is called before any message is printed out. It is
responsible for preparing message prefix and such. For example, it
might say:
@@ -114,6 +128,18 @@ struct diagnostic_context
/* Client hook to report an internal error. */
void (*internal_error) (diagnostic_context *, const char *, va_list *);
+ /* Client hook to say whether the option controlling a diagnostic is
+ enabled. Returns nonzero if enabled, zero if disabled. */
+ int (*option_enabled) (int);
+
+ /* Client hook to return the name of an option that controls a
+ diagnostic. Returns malloced memory. The first diagnostic_t
+ argument is the kind of diagnostic before any reclassification
+ (of warnings as errors, etc.); the second is the kind after any
+ reclassification. May return NULL if no name is to be printed.
+ May be passed 0 as well as the index of a particular option. */
+ char *(*option_name) (diagnostic_context *, int, diagnostic_t, diagnostic_t);
+
/* Auxiliary data for client. */
void *x_data;
@@ -187,9 +213,9 @@ extern diagnostic_context *global_dc;
#define sorrycount diagnostic_kind_count (global_dc, DK_SORRY)
/* Returns nonzero if warnings should be emitted. */
-#define diagnostic_report_warnings_p(LOC) \
- (!inhibit_warnings \
- && !(in_system_header_at (LOC) && !warn_system_headers))
+#define diagnostic_report_warnings_p(DC, LOC) \
+ (!(DC)->inhibit_warnings \
+ && !(in_system_header_at (LOC) && !(DC)->warn_system_headers))
#define report_diagnostic(D) diagnostic_report_diagnostic (global_dc, D)
@@ -203,7 +229,7 @@ extern diagnostic_context *global_dc;
((DI)->option_index = (OPTIDX))
/* Diagnostic related functions. */
-extern void diagnostic_initialize (diagnostic_context *);
+extern void diagnostic_initialize (diagnostic_context *, int);
extern void diagnostic_finish (diagnostic_context *);
extern void diagnostic_report_current_module (diagnostic_context *);