Mercurial > hg > CbC > CbC_gcc
comparison gcc/opts.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 |
---|---|
1 /* Command line option handling. | 1 /* Command line option handling. |
2 Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008 | 2 Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 |
3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify it under | 7 GCC is free software; you can redistribute it and/or modify it under |
19 <http://www.gnu.org/licenses/>. */ | 19 <http://www.gnu.org/licenses/>. */ |
20 | 20 |
21 #ifndef GCC_OPTS_H | 21 #ifndef GCC_OPTS_H |
22 #define GCC_OPTS_H | 22 #define GCC_OPTS_H |
23 | 23 |
24 #include "input.h" | |
25 #include "vec.h" | |
26 | |
24 /* Specifies how a switch's VAR_VALUE relates to its FLAG_VAR. */ | 27 /* Specifies how a switch's VAR_VALUE relates to its FLAG_VAR. */ |
25 enum cl_var_type { | 28 enum cl_var_type { |
26 /* The switch is enabled when FLAG_VAR is nonzero. */ | 29 /* The switch is enabled when FLAG_VAR is nonzero. */ |
27 CLVC_BOOLEAN, | 30 CLVC_BOOLEAN, |
28 | 31 |
35 /* The switch is enabled when VAR_VALUE is set in FLAG_VAR. */ | 38 /* The switch is enabled when VAR_VALUE is set in FLAG_VAR. */ |
36 CLVC_BIT_SET, | 39 CLVC_BIT_SET, |
37 | 40 |
38 /* The switch takes a string argument and FLAG_VAR points to that | 41 /* The switch takes a string argument and FLAG_VAR points to that |
39 argument. */ | 42 argument. */ |
40 CLVC_STRING | 43 CLVC_STRING, |
44 | |
45 /* The switch takes an enumerated argument (VAR_ENUM says what | |
46 enumeration) and FLAG_VAR points to that argument. */ | |
47 CLVC_ENUM, | |
48 | |
49 /* The switch should be stored in the VEC pointed to by FLAG_VAR for | |
50 later processing. */ | |
51 CLVC_DEFER | |
41 }; | 52 }; |
42 | 53 |
43 struct cl_option | 54 struct cl_option |
44 { | 55 { |
45 const char *opt_text; | 56 const char *opt_text; |
46 const char *help; | 57 const char *help; |
58 const char *missing_argument_error; | |
59 const char *warn_message; | |
60 const char *alias_arg; | |
61 const char *neg_alias_arg; | |
62 unsigned short alias_target; | |
47 unsigned short back_chain; | 63 unsigned short back_chain; |
48 unsigned char opt_len; | 64 unsigned char opt_len; |
49 int neg_index; | 65 int neg_index; |
50 unsigned int flags; | 66 unsigned int flags; |
51 void *flag_var; | 67 unsigned short flag_var_offset; |
68 unsigned short var_enum; | |
52 enum cl_var_type var_type; | 69 enum cl_var_type var_type; |
53 int var_value; | 70 int var_value; |
54 }; | 71 }; |
55 | 72 |
56 /* Records that the state of an option consists of SIZE bytes starting | 73 /* Records that the state of an option consists of SIZE bytes starting |
64 extern const struct cl_option cl_options[]; | 81 extern const struct cl_option cl_options[]; |
65 extern const unsigned int cl_options_count; | 82 extern const unsigned int cl_options_count; |
66 extern const char *const lang_names[]; | 83 extern const char *const lang_names[]; |
67 extern const unsigned int cl_lang_count; | 84 extern const unsigned int cl_lang_count; |
68 | 85 |
69 #define CL_PARAMS (1 << 17) /* Fake entry. Used to display --param info with --help. */ | 86 #define CL_PARAMS (1 << 11) /* Fake entry. Used to display --param info with --help. */ |
70 #define CL_WARNING (1 << 18) /* Enables an (optional) warning message. */ | 87 #define CL_WARNING (1 << 12) /* Enables an (optional) warning message. */ |
71 #define CL_OPTIMIZATION (1 << 19) /* Enables an (optional) optimization. */ | 88 #define CL_OPTIMIZATION (1 << 13) /* Enables an (optional) optimization. */ |
72 #define CL_TARGET (1 << 20) /* Target-specific option. */ | 89 #define CL_DRIVER (1 << 14) /* Driver option. */ |
73 #define CL_COMMON (1 << 21) /* Language-independent. */ | 90 #define CL_TARGET (1 << 15) /* Target-specific option. */ |
91 #define CL_COMMON (1 << 16) /* Language-independent. */ | |
74 | 92 |
75 #define CL_MIN_OPTION_CLASS CL_PARAMS | 93 #define CL_MIN_OPTION_CLASS CL_PARAMS |
76 #define CL_MAX_OPTION_CLASS CL_COMMON | 94 #define CL_MAX_OPTION_CLASS CL_COMMON |
77 | 95 |
78 /* From here on the bits describe attributes of the options. | 96 /* From here on the bits describe attributes of the options. |
79 Before this point the bits have described the class of the option. | 97 Before this point the bits have described the class of the option. |
80 This distinction is important because --help will not list options | 98 This distinction is important because --help will not list options |
81 which only have these higher bits set. */ | 99 which only have these higher bits set. */ |
82 | 100 |
101 /* Options marked with CL_SEPARATE take a number of separate arguments | |
102 (1 to 4) that is one more than the number in this bit-field. */ | |
103 #define CL_SEPARATE_NARGS_SHIFT 17 | |
104 #define CL_SEPARATE_NARGS_MASK (3 << CL_SEPARATE_NARGS_SHIFT) | |
105 | |
106 #define CL_SEPARATE_ALIAS (1 << 19) /* Option is an alias when used with separate argument. */ | |
107 #define CL_NO_DRIVER_ARG (1 << 20) /* Option takes no argument in the driver. */ | |
108 #define CL_REJECT_DRIVER (1 << 21) /* Reject this option in the driver. */ | |
83 #define CL_SAVE (1 << 22) /* Target-specific option for attribute. */ | 109 #define CL_SAVE (1 << 22) /* Target-specific option for attribute. */ |
84 #define CL_DISABLED (1 << 23) /* Disabled in this configuration. */ | 110 #define CL_DISABLED (1 << 23) /* Disabled in this configuration. */ |
85 #define CL_REPORT (1 << 24) /* Report argument with -fverbose-asm */ | 111 #define CL_REPORT (1 << 24) /* Report argument with -fverbose-asm */ |
86 #define CL_JOINED (1 << 25) /* If takes joined argument. */ | 112 #define CL_JOINED (1 << 25) /* If takes joined argument. */ |
87 #define CL_SEPARATE (1 << 26) /* If takes a separate argument. */ | 113 #define CL_SEPARATE (1 << 26) /* If takes a separate argument. */ |
88 #define CL_REJECT_NEGATIVE (1 << 27) /* Reject no- form. */ | 114 #define CL_REJECT_NEGATIVE (1 << 27) /* Reject no- form. */ |
89 #define CL_MISSING_OK (1 << 28) /* Missing argument OK (joined). */ | 115 #define CL_MISSING_OK (1 << 28) /* Missing argument OK (joined). */ |
90 #define CL_UINTEGER (1 << 29) /* Argument is an integer >=0. */ | 116 #define CL_UINTEGER (1 << 29) /* Argument is an integer >=0. */ |
91 #define CL_UNDOCUMENTED (1 << 30) /* Do not output with --help. */ | 117 #define CL_UNDOCUMENTED (1 << 30) /* Do not output with --help. */ |
92 | 118 |
119 /* Flags for an enumerated option argument. */ | |
120 #define CL_ENUM_CANONICAL (1 << 0) /* Canonical for this value. */ | |
121 #define CL_ENUM_DRIVER_ONLY (1 << 1) /* Only accepted in the driver. */ | |
122 | |
123 /* Structure describing an enumerated option argument. */ | |
124 | |
125 struct cl_enum_arg | |
126 { | |
127 /* The argument text, or NULL at the end of the array. */ | |
128 const char *arg; | |
129 | |
130 /* The corresponding integer value. */ | |
131 int value; | |
132 | |
133 /* Flags associated with this argument. */ | |
134 unsigned int flags; | |
135 }; | |
136 | |
137 /* Structure describing an enumerated set of option arguments. */ | |
138 | |
139 struct cl_enum | |
140 { | |
141 /* Help text, or NULL if the values should not be listed in --help | |
142 output. */ | |
143 const char *help; | |
144 | |
145 /* Error message for unknown arguments, or NULL to use a generic | |
146 error. */ | |
147 const char *unknown_error; | |
148 | |
149 /* Array of possible values. */ | |
150 const struct cl_enum_arg *values; | |
151 | |
152 /* The size of the type used to store a value. */ | |
153 size_t var_size; | |
154 | |
155 /* Function to set a variable of this type. */ | |
156 void (*set) (void *var, int value); | |
157 | |
158 /* Function to get the value of a variable of this type. */ | |
159 int (*get) (const void *var); | |
160 }; | |
161 | |
162 extern const struct cl_enum cl_enums[]; | |
163 extern const unsigned int cl_enums_count; | |
164 | |
165 /* Possible ways in which a command-line option may be erroneous. | |
166 These do not include not being known at all; an option index of | |
167 OPT_SPECIAL_unknown is used for that. */ | |
168 | |
169 #define CL_ERR_DISABLED (1 << 0) /* Disabled in this configuration. */ | |
170 #define CL_ERR_MISSING_ARG (1 << 1) /* Argument required but missing. */ | |
171 #define CL_ERR_WRONG_LANG (1 << 2) /* Option for wrong language. */ | |
172 #define CL_ERR_UINT_ARG (1 << 3) /* Bad unsigned integer argument. */ | |
173 #define CL_ERR_ENUM_ARG (1 << 4) /* Bad enumerated argument. */ | |
174 #define CL_ERR_NEGATIVE (1 << 5) /* Negative form of option | |
175 not permitted (together | |
176 with OPT_SPECIAL_unknown). */ | |
177 | |
178 /* Structure describing the result of decoding an option. */ | |
179 | |
180 struct cl_decoded_option | |
181 { | |
182 /* The index of this option, or an OPT_SPECIAL_* value for | |
183 non-options and unknown options. */ | |
184 size_t opt_index; | |
185 | |
186 /* Any warning to give for use of this option, or NULL if none. */ | |
187 const char *warn_message; | |
188 | |
189 /* The string argument, or NULL if none. For OPT_SPECIAL_* cases, | |
190 the option or non-option command-line argument. */ | |
191 const char *arg; | |
192 | |
193 /* The original text of option plus arguments, with separate argv | |
194 elements concatenated into one string with spaces separating | |
195 them. This is for such uses as diagnostics and | |
196 -frecord-gcc-switches. */ | |
197 const char *orig_option_with_args_text; | |
198 | |
199 /* The canonical form of the option and its argument, for when it is | |
200 necessary to reconstruct argv elements (in particular, for | |
201 processing specs and passing options to subprocesses from the | |
202 driver). */ | |
203 const char *canonical_option[4]; | |
204 | |
205 /* The number of elements in the canonical form of the option and | |
206 arguments; always at least 1. */ | |
207 size_t canonical_option_num_elements; | |
208 | |
209 /* For a boolean option, 1 for the true case and 0 for the "no-" | |
210 case. For an unsigned integer option, the value of the | |
211 argument. 1 in all other cases. */ | |
212 int value; | |
213 | |
214 /* Any flags describing errors detected in this option. */ | |
215 int errors; | |
216 }; | |
217 | |
218 /* Structure describing an option deferred for handling after the main | |
219 option handlers. */ | |
220 | |
221 typedef struct | |
222 { | |
223 /* Elements from struct cl_decoded_option used for deferred | |
224 options. */ | |
225 size_t opt_index; | |
226 const char *arg; | |
227 int value; | |
228 } cl_deferred_option; | |
229 DEF_VEC_O(cl_deferred_option); | |
230 DEF_VEC_ALLOC_O(cl_deferred_option,heap); | |
231 | |
232 /* Structure describing a single option-handling callback. */ | |
233 | |
234 struct cl_option_handler_func | |
235 { | |
236 /* The function called to handle the option. */ | |
237 bool (*handler) (struct gcc_options *opts, | |
238 struct gcc_options *opts_set, | |
239 const struct cl_decoded_option *decoded, | |
240 unsigned int lang_mask, int kind, location_t loc, | |
241 const struct cl_option_handlers *handlers, | |
242 diagnostic_context *dc); | |
243 | |
244 /* The mask that must have some bit in common with the flags for the | |
245 option for this particular handler to be used. */ | |
246 unsigned int mask; | |
247 }; | |
248 | |
249 /* Structure describing the callbacks used in handling options. */ | |
250 | |
251 struct cl_option_handlers | |
252 { | |
253 /* Callback for an unknown option to determine whether to give an | |
254 error for it, and possibly store information to diagnose the | |
255 option at a later point. Return true if an error should be | |
256 given, false otherwise. */ | |
257 bool (*unknown_option_callback) (const struct cl_decoded_option *decoded); | |
258 | |
259 /* Callback to handle, and possibly diagnose, an option for another | |
260 language. */ | |
261 void (*wrong_lang_callback) (const struct cl_decoded_option *decoded, | |
262 unsigned int lang_mask); | |
263 | |
264 /* Callback to call after the successful handling of any option. */ | |
265 void (*post_handling_callback) (const struct cl_decoded_option *decoded, | |
266 unsigned int mask); | |
267 | |
268 /* The number of individual handlers. */ | |
269 size_t num_handlers; | |
270 | |
271 /* The handlers themselves. */ | |
272 struct cl_option_handler_func handlers[3]; | |
273 }; | |
274 | |
93 /* Input file names. */ | 275 /* Input file names. */ |
94 | 276 |
95 extern const char **in_fnames; | 277 extern const char **in_fnames; |
96 | 278 |
97 /* The count of input filenames. */ | 279 /* The count of input filenames. */ |
98 | 280 |
99 extern unsigned num_in_fnames; | 281 extern unsigned num_in_fnames; |
100 | 282 |
101 size_t find_opt (const char *input, int lang_mask); | 283 size_t find_opt (const char *input, int lang_mask); |
102 extern void prune_options (int *argcp, char ***argvp); | 284 extern int integral_argument (const char *arg); |
103 extern void decode_options (unsigned int argc, const char **argv); | 285 extern bool enum_value_to_arg (const struct cl_enum_arg *enum_args, |
104 extern int option_enabled (int opt_idx); | 286 const char **argp, int value, |
105 extern bool get_option_state (int, struct cl_option_state *); | 287 unsigned int lang_mask); |
106 extern void set_option (int opt_index, int value, const char *arg, int); | 288 extern void decode_cmdline_options_to_array (unsigned int argc, |
107 bool handle_option (int opt_index, int value, const char *arg, | 289 const char **argv, |
108 unsigned int lang_mask, int kind); | 290 unsigned int lang_mask, |
109 extern void register_warning_as_error_callback (void (*callback) (int)); | 291 struct cl_decoded_option **decoded_options, |
110 extern void enable_warning_as_error (const char *arg, int value, | 292 unsigned int *decoded_options_count); |
111 unsigned int lang_mask); | 293 extern void init_options_once (void); |
294 extern void init_options_struct (struct gcc_options *opts, | |
295 struct gcc_options *opts_set); | |
296 extern void decode_cmdline_options_to_array_default_mask (unsigned int argc, | |
297 const char **argv, | |
298 struct cl_decoded_option **decoded_options, | |
299 unsigned int *decoded_options_count); | |
300 extern void set_default_handlers (struct cl_option_handlers *handlers); | |
301 extern void decode_options (struct gcc_options *opts, | |
302 struct gcc_options *opts_set, | |
303 struct cl_decoded_option *decoded_options, | |
304 unsigned int decoded_options_count, | |
305 location_t loc, | |
306 diagnostic_context *dc); | |
307 extern int option_enabled (int opt_idx, void *opts); | |
308 extern bool get_option_state (struct gcc_options *, int, | |
309 struct cl_option_state *); | |
310 extern void set_option (struct gcc_options *opts, | |
311 struct gcc_options *opts_set, | |
312 int opt_index, int value, const char *arg, int kind, | |
313 location_t loc, diagnostic_context *dc); | |
314 extern void *option_flag_var (int opt_index, struct gcc_options *opts); | |
315 bool handle_generated_option (struct gcc_options *opts, | |
316 struct gcc_options *opts_set, | |
317 size_t opt_index, const char *arg, int value, | |
318 unsigned int lang_mask, int kind, location_t loc, | |
319 const struct cl_option_handlers *handlers, | |
320 diagnostic_context *dc); | |
321 void generate_option (size_t opt_index, const char *arg, int value, | |
322 unsigned int lang_mask, | |
323 struct cl_decoded_option *decoded); | |
324 void generate_option_input_file (const char *file, | |
325 struct cl_decoded_option *decoded); | |
326 extern void read_cmdline_option (struct gcc_options *opts, | |
327 struct gcc_options *opts_set, | |
328 struct cl_decoded_option *decoded, | |
329 location_t loc, | |
330 unsigned int lang_mask, | |
331 const struct cl_option_handlers *handlers, | |
332 diagnostic_context *dc); | |
333 extern void control_warning_option (unsigned int opt_index, int kind, | |
334 bool imply, location_t loc, | |
335 unsigned int lang_mask, | |
336 const struct cl_option_handlers *handlers, | |
337 struct gcc_options *opts, | |
338 struct gcc_options *opts_set, | |
339 diagnostic_context *dc); | |
112 extern void print_ignored_options (void); | 340 extern void print_ignored_options (void); |
341 extern void handle_common_deferred_options (void); | |
342 extern bool common_handle_option (struct gcc_options *opts, | |
343 struct gcc_options *opts_set, | |
344 const struct cl_decoded_option *decoded, | |
345 unsigned int lang_mask, int kind, | |
346 location_t loc, | |
347 const struct cl_option_handlers *handlers, | |
348 diagnostic_context *dc); | |
349 extern bool target_handle_option (struct gcc_options *opts, | |
350 struct gcc_options *opts_set, | |
351 const struct cl_decoded_option *decoded, | |
352 unsigned int lang_mask, int kind, | |
353 location_t loc, | |
354 const struct cl_option_handlers *handlers, | |
355 diagnostic_context *dc); | |
356 extern void finish_options (struct gcc_options *opts, | |
357 struct gcc_options *opts_set, | |
358 location_t loc); | |
359 extern void default_options_optimization (struct gcc_options *opts, | |
360 struct gcc_options *opts_set, | |
361 struct cl_decoded_option *decoded_options, | |
362 unsigned int decoded_options_count, | |
363 location_t loc, | |
364 unsigned int lang_mask, | |
365 const struct cl_option_handlers *handlers, | |
366 diagnostic_context *dc); | |
367 extern void set_struct_debug_option (struct gcc_options *opts, | |
368 location_t loc, | |
369 const char *value); | |
113 #endif | 370 #endif |