Mercurial > hg > CbC > CbC_gcc
comparison gcc/diagnostic.h @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | b7f97abdc517 |
children | 04ced10e8804 |
comparison
equal
deleted
inserted
replaced
65:65488c3d617d | 67:f6334be47118 |
---|---|
21 | 21 |
22 #ifndef GCC_DIAGNOSTIC_H | 22 #ifndef GCC_DIAGNOSTIC_H |
23 #define GCC_DIAGNOSTIC_H | 23 #define GCC_DIAGNOSTIC_H |
24 | 24 |
25 #include "pretty-print.h" | 25 #include "pretty-print.h" |
26 #include "options.h" | 26 #include "diagnostic-core.h" |
27 | |
28 /* Constants used to discriminate diagnostics. */ | |
29 typedef enum | |
30 { | |
31 #define DEFINE_DIAGNOSTIC_KIND(K, msgid) K, | |
32 #include "diagnostic.def" | |
33 #undef DEFINE_DIAGNOSTIC_KIND | |
34 DK_LAST_DIAGNOSTIC_KIND | |
35 } diagnostic_t; | |
36 | 27 |
37 /* A diagnostic is described by the MESSAGE to send, the FILE and LINE of | 28 /* A diagnostic is described by the MESSAGE to send, the FILE and LINE of |
38 its context and its KIND (ice, error, warning, note, ...) See complete | 29 its context and its KIND (ice, error, warning, note, ...) See complete |
39 list in diagnostic.def. */ | 30 list in diagnostic.def. */ |
40 typedef struct diagnostic_info | 31 typedef struct diagnostic_info |
48 diagnostic_t kind; | 39 diagnostic_t kind; |
49 /* Which OPT_* directly controls this diagnostic. */ | 40 /* Which OPT_* directly controls this diagnostic. */ |
50 int option_index; | 41 int option_index; |
51 } diagnostic_info; | 42 } diagnostic_info; |
52 | 43 |
44 /* Each time a diagnostic's classification is changed with a pragma, | |
45 we record the change and the location of the change in an array of | |
46 these structs. */ | |
47 typedef struct diagnostic_classification_change_t | |
48 { | |
49 location_t location; | |
50 int option; | |
51 diagnostic_t kind; | |
52 } diagnostic_classification_change_t; | |
53 | |
53 /* Forward declarations. */ | 54 /* Forward declarations. */ |
54 typedef struct diagnostic_context diagnostic_context; | |
55 typedef void (*diagnostic_starter_fn) (diagnostic_context *, | 55 typedef void (*diagnostic_starter_fn) (diagnostic_context *, |
56 diagnostic_info *); | 56 diagnostic_info *); |
57 typedef diagnostic_starter_fn diagnostic_finalizer_fn; | 57 typedef diagnostic_starter_fn diagnostic_finalizer_fn; |
58 | 58 |
59 /* This data structure bundles altogether any information relevant to | 59 /* This data structure bundles altogether any information relevant to |
71 bool some_warnings_are_errors; | 71 bool some_warnings_are_errors; |
72 | 72 |
73 /* True if it has been requested that warnings be treated as errors. */ | 73 /* True if it has been requested that warnings be treated as errors. */ |
74 bool warning_as_error_requested; | 74 bool warning_as_error_requested; |
75 | 75 |
76 /* For each option index that can be passed to warning() et all | 76 /* The number of option indexes that can be passed to warning() et |
77 (OPT_* from options.h), this array may contain a new kind that | 77 al. */ |
78 the diagnostic should be changed to before reporting, or | 78 int n_opts; |
79 DK_UNSPECIFIED to leave it as the reported kind, or DK_IGNORED to | 79 |
80 not report it at all. N_OPTS is from <options.h>. */ | 80 /* For each option index that can be passed to warning() et al |
81 diagnostic_t classify_diagnostic[N_OPTS]; | 81 (OPT_* from options.h when using this code with the core GCC |
82 options), this array may contain a new kind that the diagnostic | |
83 should be changed to before reporting, or DK_UNSPECIFIED to leave | |
84 it as the reported kind, or DK_IGNORED to not report it at | |
85 all. */ | |
86 diagnostic_t *classify_diagnostic; | |
87 | |
88 /* History of all changes to the classifications above. This list | |
89 is stored in location-order, so we can search it, either | |
90 binary-wise or end-to-front, to find the most recent | |
91 classification for a given diagnostic, given the location of the | |
92 diagnostic. */ | |
93 diagnostic_classification_change_t *classification_history; | |
94 | |
95 /* The size of the above array. */ | |
96 int n_classification_history; | |
97 | |
98 /* For pragma push/pop. */ | |
99 int *push_list; | |
100 int n_push; | |
82 | 101 |
83 /* True if we should print the command line option which controls | 102 /* True if we should print the command line option which controls |
84 each diagnostic, if known. */ | 103 each diagnostic, if known. */ |
85 bool show_option_requested; | 104 bool show_option_requested; |
86 | 105 |
87 /* True if we should raise a SIGABRT on errors. */ | 106 /* True if we should raise a SIGABRT on errors. */ |
88 bool abort_on_error; | 107 bool abort_on_error; |
108 | |
109 /* True if we should show the column number on diagnostics. */ | |
110 bool show_column; | |
111 | |
112 /* True if pedwarns are errors. */ | |
113 bool pedantic_errors; | |
114 | |
115 /* True if permerrors are warnings. */ | |
116 bool permissive; | |
117 | |
118 /* The index of the option to associate with turning permerrors into | |
119 warnings. */ | |
120 int opt_permissive; | |
121 | |
122 /* True if errors are fatal. */ | |
123 bool fatal_errors; | |
124 | |
125 /* True if all warnings should be disabled. */ | |
126 bool dc_inhibit_warnings; | |
127 | |
128 /* True if warnings should be given in system headers. */ | |
129 bool dc_warn_system_headers; | |
130 | |
131 /* Maximum number of errors to report. */ | |
132 unsigned int max_errors; | |
89 | 133 |
90 /* This function is called before any message is printed out. It is | 134 /* This function is called before any message is printed out. It is |
91 responsible for preparing message prefix and such. For example, it | 135 responsible for preparing message prefix and such. For example, it |
92 might say: | 136 might say: |
93 In file included from "/usr/local/include/curses.h:5: | 137 In file included from "/usr/local/include/curses.h:5: |
98 | 142 |
99 /* This function is called after the diagnostic message is printed. */ | 143 /* This function is called after the diagnostic message is printed. */ |
100 diagnostic_finalizer_fn end_diagnostic; | 144 diagnostic_finalizer_fn end_diagnostic; |
101 | 145 |
102 /* Client hook to report an internal error. */ | 146 /* Client hook to report an internal error. */ |
103 void (*internal_error) (const char *, va_list *); | 147 void (*internal_error) (diagnostic_context *, const char *, va_list *); |
148 | |
149 /* Client hook to say whether the option controlling a diagnostic is | |
150 enabled. Returns nonzero if enabled, zero if disabled. */ | |
151 int (*option_enabled) (int, void *); | |
152 | |
153 /* Client information to pass as second argument to | |
154 option_enabled. */ | |
155 void *option_state; | |
156 | |
157 /* Client hook to return the name of an option that controls a | |
158 diagnostic. Returns malloced memory. The first diagnostic_t | |
159 argument is the kind of diagnostic before any reclassification | |
160 (of warnings as errors, etc.); the second is the kind after any | |
161 reclassification. May return NULL if no name is to be printed. | |
162 May be passed 0 as well as the index of a particular option. */ | |
163 char *(*option_name) (diagnostic_context *, int, diagnostic_t, diagnostic_t); | |
104 | 164 |
105 /* Auxiliary data for client. */ | 165 /* Auxiliary data for client. */ |
106 void *x_data; | 166 void *x_data; |
107 | 167 |
108 /* Used to detect when the input file stack has changed since last | 168 /* Used to detect when the input file stack has changed since last |
173 #define warningcount diagnostic_kind_count (global_dc, DK_WARNING) | 233 #define warningcount diagnostic_kind_count (global_dc, DK_WARNING) |
174 /* Similarly, but for sorrys. */ | 234 /* Similarly, but for sorrys. */ |
175 #define sorrycount diagnostic_kind_count (global_dc, DK_SORRY) | 235 #define sorrycount diagnostic_kind_count (global_dc, DK_SORRY) |
176 | 236 |
177 /* Returns nonzero if warnings should be emitted. */ | 237 /* Returns nonzero if warnings should be emitted. */ |
178 #define diagnostic_report_warnings_p(LOC) \ | 238 #define diagnostic_report_warnings_p(DC, LOC) \ |
179 (!inhibit_warnings \ | 239 (!(DC)->dc_inhibit_warnings \ |
180 && !(in_system_header_at (LOC) && !warn_system_headers)) | 240 && !(in_system_header_at (LOC) && !(DC)->dc_warn_system_headers)) |
181 | 241 |
182 #define report_diagnostic(D) diagnostic_report_diagnostic (global_dc, D) | 242 #define report_diagnostic(D) diagnostic_report_diagnostic (global_dc, D) |
183 | 243 |
184 /* Override the column number to be used for reporting a | 244 /* Override the column number to be used for reporting a |
185 diagnostic. */ | 245 diagnostic. */ |
189 diagnostic. */ | 249 diagnostic. */ |
190 #define diagnostic_override_option_index(DI, OPTIDX) \ | 250 #define diagnostic_override_option_index(DI, OPTIDX) \ |
191 ((DI)->option_index = (OPTIDX)) | 251 ((DI)->option_index = (OPTIDX)) |
192 | 252 |
193 /* Diagnostic related functions. */ | 253 /* Diagnostic related functions. */ |
194 extern void diagnostic_initialize (diagnostic_context *); | 254 extern void diagnostic_initialize (diagnostic_context *, int); |
195 extern void diagnostic_finish (diagnostic_context *); | 255 extern void diagnostic_finish (diagnostic_context *); |
196 extern void diagnostic_report_current_module (diagnostic_context *); | 256 extern void diagnostic_report_current_module (diagnostic_context *); |
197 | 257 |
198 /* Force diagnostics controlled by OPTIDX to be kind KIND. */ | 258 /* Force diagnostics controlled by OPTIDX to be kind KIND. */ |
199 extern diagnostic_t diagnostic_classify_diagnostic (diagnostic_context *, | 259 extern diagnostic_t diagnostic_classify_diagnostic (diagnostic_context *, |
200 int /* optidx */, | 260 int /* optidx */, |
201 diagnostic_t /* kind */); | 261 diagnostic_t /* kind */, |
262 location_t); | |
263 extern void diagnostic_push_diagnostics (diagnostic_context *, location_t); | |
264 extern void diagnostic_pop_diagnostics (diagnostic_context *, location_t); | |
202 extern bool diagnostic_report_diagnostic (diagnostic_context *, | 265 extern bool diagnostic_report_diagnostic (diagnostic_context *, |
203 diagnostic_info *); | 266 diagnostic_info *); |
204 #ifdef ATTRIBUTE_GCC_DIAG | 267 #ifdef ATTRIBUTE_GCC_DIAG |
205 extern void diagnostic_set_info (diagnostic_info *, const char *, va_list *, | 268 extern void diagnostic_set_info (diagnostic_info *, const char *, va_list *, |
206 location_t, diagnostic_t) ATTRIBUTE_GCC_DIAG(2,0); | 269 location_t, diagnostic_t) ATTRIBUTE_GCC_DIAG(2,0); |
207 extern void diagnostic_set_info_translated (diagnostic_info *, const char *, | 270 extern void diagnostic_set_info_translated (diagnostic_info *, const char *, |
208 va_list *, location_t, | 271 va_list *, location_t, |
209 diagnostic_t) | 272 diagnostic_t) |
210 ATTRIBUTE_GCC_DIAG(2,0); | 273 ATTRIBUTE_GCC_DIAG(2,0); |
211 extern bool emit_diagnostic (diagnostic_t, location_t, int, | |
212 const char *, ...) ATTRIBUTE_GCC_DIAG(4,5); | |
213 #endif | 274 #endif |
214 extern char *diagnostic_build_prefix (diagnostic_info *); | 275 extern char *diagnostic_build_prefix (diagnostic_context *, diagnostic_info *); |
215 void default_diagnostic_starter (diagnostic_context *, diagnostic_info *); | 276 void default_diagnostic_starter (diagnostic_context *, diagnostic_info *); |
216 void default_diagnostic_finalizer (diagnostic_context *, diagnostic_info *); | 277 void default_diagnostic_finalizer (diagnostic_context *, diagnostic_info *); |
217 | 278 |
218 /* Pure text formatting support functions. */ | 279 /* Pure text formatting support functions. */ |
219 extern char *file_name_as_prefix (const char *); | 280 extern char *file_name_as_prefix (const char *); |