1 /* C/ObjC/C++ command line option handling.
2 Copyright (C) 2002, 2003 Free Software Foundation, Inc.
3 Contributed by Neil Booth.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 #include "coretypes.h"
31 #include "langhooks.h"
32 #include "tree-inline.h"
33 #include "diagnostic.h"
35 #include "cppdefault.h"
36 #include "c-incpath.h"
38 #ifndef TARGET_SYSTEM_ROOT
39 # define TARGET_SYSTEM_ROOT NULL
43 static cpp_options *cpp_opts;
46 static const char *in_fname;
48 /* Filename and stream for preprocessed output. */
49 static const char *out_fname;
50 static FILE *out_stream;
52 /* Append dependencies to deps_file. */
53 static bool deps_append;
55 /* If dependency switches (-MF etc.) have been given. */
56 static bool deps_seen;
61 /* Dependency output file. */
62 static const char *deps_file;
64 /* The prefix given by -iprefix, if any. */
65 static const char *iprefix;
67 /* The system root, if any. Overridden by -isysroot. */
68 static const char *sysroot = TARGET_SYSTEM_ROOT;
70 /* Zero disables all standard directories for headers. */
71 static bool std_inc = true;
73 /* Zero disables the C++-specific standard directories for headers. */
74 static bool std_cxx_inc = true;
76 /* If the quote chain has been split by -I-. */
77 static bool quote_chain_split;
79 /* Number of deferred options, deferred options array size. */
80 static size_t deferred_count, deferred_size;
82 static void missing_arg PARAMS ((size_t));
83 static size_t find_opt PARAMS ((const char *, int));
84 static void set_Wimplicit PARAMS ((int));
85 static void complain_wrong_lang PARAMS ((size_t));
86 static void write_langs PARAMS ((char *, int));
87 static void print_help PARAMS ((void));
88 static void handle_OPT_d PARAMS ((const char *));
89 static void set_std_cxx98 PARAMS ((int));
90 static void set_std_c89 PARAMS ((int, int));
91 static void set_std_c99 PARAMS ((int));
92 static void check_deps_environment_vars PARAMS ((void));
93 static void handle_deferred_opts PARAMS ((void));
94 static void sanitize_cpp_opts PARAMS ((void));
95 static void add_prefixed_path PARAMS ((const char *, size_t));
97 #ifndef STDC_0_IN_SYSTEM_HEADERS
98 #define STDC_0_IN_SYSTEM_HEADERS 0
101 #define CL_C_ONLY (1 << 0) /* Only C. */
102 #define CL_OBJC_ONLY (1 << 1) /* Only ObjC. */
103 #define CL_CXX_ONLY (1 << 2) /* Only C++. */
104 #define CL_OBJCXX_ONLY (1 << 3) /* Only ObjC++. */
105 #define CL_JOINED (1 << 4) /* If takes joined argument. */
106 #define CL_SEPARATE (1 << 5) /* If takes a separate argument. */
108 #define CL_ARG (CL_JOINED | CL_SEPARATE)
109 #define CL_C (CL_C_ONLY | CL_OBJC_ONLY)
110 #define CL_OBJC (CL_OBJC_ONLY | CL_OBJCXX_ONLY)
111 #define CL_CXX (CL_CXX_ONLY | CL_OBJCXX_ONLY)
112 #define CL_ALL (CL_C | CL_CXX)
114 /* This is the list of all command line options, with the leading "-"
115 removed. It must be sorted in ASCII collating order. All options
116 beginning with "f" or "W" are implicitly assumed to take a "no-"
117 form; this form should not be listed. The variable "on" is true if
118 the positive form is given, otherwise it is false. If you don't
119 want to allow a "no-" form, your handler should reject "on" being
120 false by returning zero. See, for example, the handling of
123 If the user gives an option to a front end that doesn't support it,
124 an error is output, mentioning which front ends the option is valid
125 for. If you don't want this, you must accept it for all front
126 ends, and test for the front end in the option handler. See, for
127 example, the handling of -Wno-strict-prototypes for C++.
129 If you request an argument with CL_JOINED, CL_SEPARATE or their
130 combination CL_ARG, it is stored in the variable "arg", which is
131 guaranteed to be non-NULL and to not be an empty string. It points
132 to the argument either within the argv[] vector or within one of
133 that vector's strings, and so the text is permanent and copies need
134 not be made. Be sure to add an error message in missing_arg() if
135 the default is not appropriate. */
137 #define COMMAND_LINE_OPTIONS \
138 OPT("-help", CL_ALL, OPT__help) \
139 OPT("-output-pch=", CL_ALL | CL_ARG, OPT__output_pch) \
140 OPT("C", CL_ALL, OPT_C) \
141 OPT("CC", CL_ALL, OPT_CC) \
142 OPT("E", CL_ALL, OPT_E) \
143 OPT("H", CL_ALL, OPT_H) \
144 OPT("I", CL_ALL | CL_ARG, OPT_I) \
145 OPT("M", CL_ALL, OPT_M) \
146 OPT("MD", CL_ALL | CL_SEPARATE, OPT_MD) \
147 OPT("MF", CL_ALL | CL_ARG, OPT_MF) \
148 OPT("MG", CL_ALL, OPT_MG) \
149 OPT("MM", CL_ALL, OPT_MM) \
150 OPT("MMD", CL_ALL | CL_SEPARATE, OPT_MMD) \
151 OPT("MP", CL_ALL, OPT_MP) \
152 OPT("MQ", CL_ALL | CL_ARG, OPT_MQ) \
153 OPT("MT", CL_ALL | CL_ARG, OPT_MT) \
154 OPT("P", CL_ALL, OPT_P) \
155 OPT("Wabi", CL_CXX, OPT_Wabi) \
156 OPT("Wall", CL_ALL, OPT_Wall) \
157 OPT("Wbad-function-cast", CL_C, OPT_Wbad_function_cast) \
158 OPT("Wcast-qual", CL_ALL, OPT_Wcast_qual) \
159 OPT("Wchar-subscripts", CL_ALL, OPT_Wchar_subscripts) \
160 OPT("Wcomment", CL_ALL, OPT_Wcomment) \
161 OPT("Wcomments", CL_ALL, OPT_Wcomments) \
162 OPT("Wconversion", CL_ALL, OPT_Wconversion) \
163 OPT("Wctor-dtor-privacy", CL_CXX, OPT_Wctor_dtor_privacy) \
164 OPT("Wdeprecated", CL_CXX, OPT_Wdeprecated) \
165 OPT("Wdiv-by-zero", CL_C, OPT_Wdiv_by_zero) \
166 OPT("Weffc++", CL_CXX, OPT_Weffcxx) \
167 OPT("Wendif-labels", CL_ALL, OPT_Wendif_labels) \
168 OPT("Werror", CL_ALL, OPT_Werror) \
169 OPT("Werror-implicit-function-declaration", \
170 CL_C, OPT_Werror_implicit_function_decl) \
171 OPT("Wfloat-equal", CL_ALL, OPT_Wfloat_equal) \
172 OPT("Wformat", CL_ALL, OPT_Wformat) \
173 OPT("Wformat-extra-args", CL_ALL, OPT_Wformat_extra_args) \
174 OPT("Wformat-nonliteral", CL_ALL, OPT_Wformat_nonliteral) \
175 OPT("Wformat-security", CL_ALL, OPT_Wformat_security) \
176 OPT("Wformat-y2k", CL_ALL, OPT_Wformat_y2k) \
177 OPT("Wformat-zero-length", CL_C, OPT_Wformat_zero_length) \
178 OPT("Wformat=", CL_ALL | CL_JOINED, OPT_Wformat_eq) \
179 OPT("Wimplicit", CL_ALL, OPT_Wimplicit) \
180 OPT("Wimplicit-function-declaration", CL_C, OPT_Wimplicit_function_decl) \
181 OPT("Wimplicit-int", CL_C, OPT_Wimplicit_int) \
182 OPT("Wimport", CL_ALL, OPT_Wimport) \
183 OPT("Winvalid-pch", CL_ALL, OPT_Winvalid_pch) \
184 OPT("Wlong-long", CL_ALL, OPT_Wlong_long) \
185 OPT("Wmain", CL_C, OPT_Wmain) \
186 OPT("Wmissing-braces", CL_ALL, OPT_Wmissing_braces) \
187 OPT("Wmissing-declarations", CL_C, OPT_Wmissing_declarations) \
188 OPT("Wmissing-format-attribute",CL_ALL, OPT_Wmissing_format_attribute) \
189 OPT("Wmissing-prototypes", CL_ALL, OPT_Wmissing_prototypes) \
190 OPT("Wmultichar", CL_ALL, OPT_Wmultichar) \
191 OPT("Wnested-externs", CL_C, OPT_Wnested_externs) \
192 OPT("Wnon-template-friend", CL_CXX, OPT_Wnon_template_friend) \
193 OPT("Wnon-virtual-dtor", CL_CXX, OPT_Wnon_virtual_dtor) \
194 OPT("Wnonnull", CL_C, OPT_Wnonnull) \
195 OPT("Wold-style-cast", CL_CXX, OPT_Wold_style_cast) \
196 OPT("Woverloaded-virtual", CL_CXX, OPT_Woverloaded_virtual) \
197 OPT("Wparentheses", CL_ALL, OPT_Wparentheses) \
198 OPT("Wpmf-conversions", CL_CXX, OPT_Wpmf_conversions) \
199 OPT("Wpointer-arith", CL_ALL, OPT_Wpointer_arith) \
200 OPT("Wprotocol", CL_OBJC, OPT_Wprotocol) \
201 OPT("Wredundant-decls", CL_ALL, OPT_Wredundant_decls) \
202 OPT("Wreorder", CL_CXX, OPT_Wreorder) \
203 OPT("Wreturn-type", CL_ALL, OPT_Wreturn_type) \
204 OPT("Wselector", CL_OBJC, OPT_Wselector) \
205 OPT("Wsequence-point", CL_C, OPT_Wsequence_point) \
206 OPT("Wsign-compare", CL_ALL, OPT_Wsign_compare) \
207 OPT("Wsign-promo", CL_CXX, OPT_Wsign_promo) \
208 OPT("Wstrict-prototypes", CL_ALL, OPT_Wstrict_prototypes) \
209 OPT("Wsynth", CL_CXX, OPT_Wsynth) \
210 OPT("Wsystem-headers", CL_ALL, OPT_Wsystem_headers) \
211 OPT("Wtraditional", CL_C, OPT_Wtraditional) \
212 OPT("Wtrigraphs", CL_ALL, OPT_Wtrigraphs) \
213 OPT("Wundeclared-selector", CL_OBJC, OPT_Wundeclared_selector) \
214 OPT("Wundef", CL_ALL, OPT_Wundef) \
215 OPT("Wunknown-pragmas", CL_ALL, OPT_Wunknown_pragmas) \
216 OPT("Wunused-macros", CL_ALL, OPT_Wunused_macros) \
217 OPT("Wwrite-strings", CL_ALL, OPT_Wwrite_strings) \
218 OPT("ansi", CL_ALL, OPT_ansi) \
219 OPT("d", CL_ALL | CL_JOINED, OPT_d) \
220 OPT("fabi-version=", CL_CXX | CL_JOINED, OPT_fabi_version) \
221 OPT("faccess-control", CL_CXX, OPT_faccess_control) \
222 OPT("fall-virtual", CL_CXX, OPT_fall_virtual) \
223 OPT("falt-external-templates",CL_CXX, OPT_falt_external_templates) \
224 OPT("fasm", CL_ALL, OPT_fasm) \
225 OPT("fbuiltin", CL_ALL, OPT_fbuiltin) \
226 OPT("fbuiltin-", CL_ALL | CL_JOINED, OPT_fbuiltin_) \
227 OPT("fcheck-new", CL_CXX, OPT_fcheck_new) \
228 OPT("fcond-mismatch", CL_ALL, OPT_fcond_mismatch) \
229 OPT("fconserve-space", CL_CXX, OPT_fconserve_space) \
230 OPT("fconst-strings", CL_CXX, OPT_fconst_strings) \
231 OPT("fconstant-string-class=", CL_OBJC | CL_JOINED, \
232 OPT_fconstant_string_class) \
233 OPT("fdefault-inline", CL_CXX, OPT_fdefault_inline) \
234 OPT("fdollars-in-identifiers",CL_ALL, OPT_fdollars_in_identifiers) \
235 OPT("fdump-", CL_ALL | CL_JOINED, OPT_fdump) \
236 OPT("felide-constructors", CL_CXX, OPT_felide_constructors) \
237 OPT("fenforce-eh-specs", CL_CXX, OPT_fenforce_eh_specs) \
238 OPT("fenum-int-equiv", CL_CXX, OPT_fenum_int_equiv) \
239 OPT("fexternal-templates", CL_CXX, OPT_fexternal_templates) \
240 OPT("ffixed-form", CL_C, OPT_ffixed_form) \
241 OPT("ffixed-line-length-", CL_C | CL_JOINED, OPT_ffixed_line_length) \
242 OPT("ffor-scope", CL_CXX, OPT_ffor_scope) \
243 OPT("ffreestanding", CL_C, OPT_ffreestanding) \
244 OPT("fgnu-keywords", CL_CXX, OPT_fgnu_keywords) \
245 OPT("fgnu-runtime", CL_OBJC, OPT_fgnu_runtime) \
246 OPT("fguiding-decls", CL_CXX, OPT_fguiding_decls) \
247 OPT("fhandle-exceptions", CL_CXX, OPT_fhandle_exceptions) \
248 OPT("fhonor-std", CL_CXX, OPT_fhonor_std) \
249 OPT("fhosted", CL_C, OPT_fhosted) \
250 OPT("fhuge-objects", CL_CXX, OPT_fhuge_objects) \
251 OPT("fimplement-inlines", CL_CXX, OPT_fimplement_inlines) \
252 OPT("fimplicit-inline-templates", CL_CXX, OPT_fimplicit_inline_templates) \
253 OPT("fimplicit-templates", CL_CXX, OPT_fimplicit_templates) \
254 OPT("flabels-ok", CL_CXX, OPT_flabels_ok) \
255 OPT("fms-extensions", CL_ALL, OPT_fms_extensions) \
256 OPT("fname-mangling-version-",CL_CXX | CL_JOINED, OPT_fname_mangling) \
257 OPT("fnew-abi", CL_CXX, OPT_fnew_abi) \
258 OPT("fnext-runtime", CL_OBJC, OPT_fnext_runtime) \
259 OPT("fnonansi-builtins", CL_CXX, OPT_fnonansi_builtins) \
260 OPT("fnonnull-objects", CL_CXX, OPT_fnonnull_objects) \
261 OPT("foperator-names", CL_CXX, OPT_foperator_names) \
262 OPT("foptional-diags", CL_CXX, OPT_foptional_diags) \
263 OPT("fpch-deps", CL_ALL, OPT_fpch_deps) \
264 OPT("fpermissive", CL_CXX, OPT_fpermissive) \
265 OPT("fpreprocessed", CL_ALL, OPT_fpreprocessed) \
266 OPT("frepo", CL_CXX, OPT_frepo) \
267 OPT("frtti", CL_CXX, OPT_frtti) \
268 OPT("fshort-double", CL_ALL, OPT_fshort_double) \
269 OPT("fshort-enums", CL_ALL, OPT_fshort_enums) \
270 OPT("fshort-wchar", CL_ALL, OPT_fshort_wchar) \
271 OPT("fshow-column", CL_ALL, OPT_fshow_column) \
272 OPT("fsigned-bitfields", CL_ALL, OPT_fsigned_bitfields) \
273 OPT("fsigned-char", CL_ALL, OPT_fsigned_char) \
274 OPT("fsquangle", CL_CXX, OPT_fsquangle) \
275 OPT("fstats", CL_CXX, OPT_fstats) \
276 OPT("fstrict-prototype", CL_CXX, OPT_fstrict_prototype) \
277 OPT("ftabstop=", CL_ALL | CL_JOINED, OPT_ftabstop) \
278 OPT("ftemplate-depth-", CL_CXX | CL_JOINED, OPT_ftemplate_depth) \
279 OPT("fthis-is-variable", CL_CXX, OPT_fthis_is_variable) \
280 OPT("funsigned-bitfields", CL_ALL, OPT_funsigned_bitfields) \
281 OPT("funsigned-char", CL_ALL, OPT_funsigned_char) \
282 OPT("fuse-cxa-atexit", CL_CXX, OPT_fuse_cxa_atexit) \
283 OPT("fvtable-gc", CL_CXX, OPT_fvtable_gc) \
284 OPT("fvtable-thunks", CL_CXX, OPT_fvtable_thunks) \
285 OPT("fweak", CL_CXX, OPT_fweak) \
286 OPT("fxref", CL_CXX, OPT_fxref) \
287 OPT("gen-decls", CL_OBJC, OPT_gen_decls) \
288 OPT("idirafter", CL_ALL | CL_ARG, OPT_idirafter) \
289 OPT("iprefix", CL_ALL | CL_ARG, OPT_iprefix) \
290 OPT("isysroot", CL_ALL | CL_ARG, OPT_isysroot) \
291 OPT("isystem", CL_ALL | CL_ARG, OPT_isystem) \
292 OPT("iwithprefix", CL_ALL | CL_ARG, OPT_iwithprefix) \
293 OPT("iwithprefixbefore", CL_ALL | CL_ARG, OPT_iwithprefixbefore) \
294 OPT("lang-asm", CL_C_ONLY, OPT_lang_asm) \
295 OPT("lang-objc", CL_ALL, OPT_lang_objc) \
296 OPT("nostdinc", CL_ALL, OPT_nostdinc) \
297 OPT("nostdinc++", CL_ALL, OPT_nostdincplusplus) \
298 OPT("o", CL_ALL | CL_ARG, OPT_o) \
299 OPT("pedantic", CL_ALL, OPT_pedantic) \
300 OPT("pedantic-errors", CL_ALL, OPT_pedantic_errors) \
301 OPT("print-objc-runtime-info", CL_OBJC, OPT_print_objc_runtime_info) \
302 OPT("remap", CL_ALL, OPT_remap) \
303 OPT("std=c++98", CL_CXX, OPT_std_cplusplus98) \
304 OPT("std=c89", CL_C, OPT_std_c89) \
305 OPT("std=c99", CL_C, OPT_std_c99) \
306 OPT("std=c9x", CL_C, OPT_std_c9x) \
307 OPT("std=gnu++98", CL_CXX, OPT_std_gnuplusplus98) \
308 OPT("std=gnu89", CL_C, OPT_std_gnu89) \
309 OPT("std=gnu99", CL_C, OPT_std_gnu99) \
310 OPT("std=gnu9x", CL_C, OPT_std_gnu9x) \
311 OPT("std=iso9899:1990", CL_C, OPT_std_iso9899_1990) \
312 OPT("std=iso9899:199409", CL_C, OPT_std_iso9899_199409) \
313 OPT("std=iso9899:1999", CL_C, OPT_std_iso9899_1999) \
314 OPT("std=iso9899:199x", CL_C, OPT_std_iso9899_199x) \
315 OPT("traditional-cpp", CL_ALL, OPT_traditional_cpp) \
316 OPT("trigraphs", CL_ALL, OPT_trigraphs) \
317 OPT("undef", CL_ALL, OPT_undef) \
318 OPT("v", CL_ALL, OPT_v) \
319 OPT("w", CL_ALL, OPT_w)
321 #define OPT(text, flags, code) code,
331 const char *opt_text;
332 unsigned char opt_len;
334 ENUM_BITFIELD (opt_code) opt_code : 2 * CHAR_BIT;
337 #define OPT(text, flags, code) { text, sizeof(text) - 1, flags, code },
339 static struct cl_option cl_options[] =
341 static const struct cl_option cl_options[] =
347 #undef COMMAND_LINE_OPTIONS
349 /* Holds switches parsed by c_common_decode_option (), but whose
350 handling is deferred to c_common_post_options (). */
351 static void defer_opt PARAMS ((enum opt_code, const char *));
352 static struct deferred_opt
360 static int opt_comp PARAMS ((const void *, const void *));
362 /* Run-time sorting of options array. */
367 return strcmp (((struct cl_option *) p1)->opt_text,
368 ((struct cl_option *) p2)->opt_text);
372 /* Complain that switch OPT_INDEX expects an argument but none was
375 missing_arg (opt_index)
378 const char *opt_text = cl_options[opt_index].opt_text;
380 switch (cl_options[opt_index].opt_code)
382 case OPT__output_pch:
385 case OPT_fabi_version:
388 case OPT_fname_mangling:
390 case OPT_ftemplate_depth:
392 case OPT_iwithprefix:
393 case OPT_iwithprefixbefore:
395 error ("missing argument to \"-%s\"", opt_text);
398 case OPT_fconstant_string_class:
399 error ("no class name specified with \"-%s\"", opt_text);
406 error ("missing path after \"-%s\"", opt_text);
413 error ("missing filename after \"-%s\"", opt_text);
418 error ("missing target after \"-%s\"", opt_text);
423 /* Perform a binary search to find which option the command-line INPUT
424 matches. Returns its index in the option array, and N_OPTS on
427 Complications arise since some options can be suffixed with an
428 argument, and multiple complete matches can occur, e.g. -pedantic
429 and -pedantic-errors. Also, some options are only accepted by some
430 languages. If a switch matches for a different language and
431 doesn't match any alternatives for the true front end, the index of
432 the matched switch is returned anyway. The caller should check for
435 find_opt (input, lang_flag)
441 size_t result = N_OPTS;
451 opt_len = cl_options[md].opt_len;
452 comp = strncmp (input, cl_options[md].opt_text, opt_len);
460 /* The switch matches. It it an exact match? */
461 if (input[opt_len] == '\0')
467 /* If the switch takes no arguments this is not a proper
468 match, so we continue the search (e.g. input="stdc++"
469 match was "stdc"). */
470 if (!(cl_options[md].flags & CL_JOINED))
473 /* Is this switch valid for this front end? */
474 if (!(cl_options[md].flags & lang_flag))
476 /* If subsequently we don't find a better match,
477 return this and let the caller report it as a bad
483 /* Two scenarios remain: we have the switch's argument,
484 or we match a longer option. This can happen with
485 -iwithprefix and -withprefixbefore. The longest
486 possible option match succeeds.
488 Scan forwards, and return an exact match. Otherwise
489 return the longest valid option-accepting match (mx).
490 This loops at most twice with current options. */
492 for (md = md + 1; md < (size_t) N_OPTS; md++)
494 opt_len = cl_options[md].opt_len;
495 if (strncmp (input, cl_options[md].opt_text, opt_len))
497 if (input[opt_len] == '\0')
499 if (cl_options[md].flags & lang_flag
500 && cl_options[md].flags & CL_JOINED)
512 /* Defer option CODE with argument ARG. */
514 defer_opt (code, arg)
518 /* FIXME: this should be in c_common_init_options, which should take
522 extern int save_argc;
523 deferred_size = save_argc;
524 deferred_opts = (struct deferred_opt *)
525 xmalloc (deferred_size * sizeof (struct deferred_opt));
528 if (deferred_count == deferred_size)
531 deferred_opts[deferred_count].code = code;
532 deferred_opts[deferred_count].arg = arg;
536 /* Common initialization before parsing options. */
538 c_common_init_options (lang)
539 enum c_language_kind lang;
542 /* For non-ASCII hosts, the cl_options array needs to be sorted at
544 qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp);
550 for (i = 1; i < N_OPTS; i++)
551 if (strcmp (cl_options[i - 1].opt_text, cl_options[i].opt_text) >= 0)
552 error ("options array incorrectly sorted: %s is before %s",
553 cl_options[i - 1].opt_text, cl_options[i].opt_text);
558 parse_in = cpp_create_reader (lang == clk_c ? CLK_GNUC89 : CLK_GNUCXX);
559 cpp_opts = cpp_get_options (parse_in);
563 flag_const_strings = (lang == clk_cplusplus);
564 warn_pointer_arith = (lang == clk_cplusplus);
566 warn_sign_compare = -1;
569 /* Handle one command-line option in (argc, argv).
570 Can be called multiple times, to handle multiple sets of options.
571 Returns number of strings consumed. */
573 c_common_decode_option (argc, argv)
577 static const int lang_flags[] = {CL_C_ONLY, CL_C, CL_CXX_ONLY, CL_CXX};
579 const char *opt, *arg = 0;
582 int result, lang_flag;
583 const struct cl_option *option;
588 /* Interpret "-" or a non-switch as a file name. */
589 if (opt[0] != '-' || opt[1] == '\0')
597 error ("too many filenames given. Type %s --help for usage",
605 /* Drop the "no-" from negative switches. */
606 if ((opt[1] == 'W' || opt[1] == 'f')
607 && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
609 size_t len = strlen (opt) - 3;
611 dup = xmalloc (len + 1);
614 memcpy (dup + 2, opt + 5, len - 2 + 1);
619 result = cpp_handle_option (parse_in, argc, argv);
622 lang_flag = lang_flags[(c_language << 1) + flag_objc];
623 opt_index = find_opt (opt + 1, lang_flag);
624 if (opt_index == N_OPTS)
628 option = &cl_options[opt_index];
630 /* Sort out any argument the switch takes. */
631 if (option->flags & CL_ARG)
633 if (option->flags & CL_JOINED)
635 /* Have arg point to the original switch. This is because
636 some code, such as disable_builtin_function, expects its
637 argument to be persistent until the program exits. */
638 arg = argv[0] + cl_options[opt_index].opt_len + 1;
640 arg += strlen ("no-");
643 /* If we don't have an argument, and CL_SEPARATE, try the next
644 argument in the vector. */
645 if (!arg || (*arg == '\0' && option->flags & CL_SEPARATE))
651 if (!arg || *arg == '\0')
653 missing_arg (opt_index);
659 /* Complain about the wrong language after we've swallowed any
660 necessary extra argument. Eventually make this a hard error
661 after the call to find_opt, and return argc. */
662 if (!(cl_options[opt_index].flags & lang_flag))
664 complain_wrong_lang (opt_index);
668 switch (code = option->opt_code)
670 case N_OPTS: /* Shut GCC up. */
677 case OPT__output_pch:
682 cpp_opts->discard_comments = 0;
686 cpp_opts->discard_comments = 0;
687 cpp_opts->discard_comments_in_macro_exp = 0;
691 flag_preprocess_only = 1;
695 cpp_opts->print_include_names = 1;
699 if (strcmp (arg, "-"))
700 add_path (xstrdup (arg), BRACKET, 0);
703 if (quote_chain_split)
704 error ("-I- specified twice");
705 quote_chain_split = true;
706 split_quote_chain ();
712 /* When doing dependencies with -M or -MM, suppress normal
713 preprocessed output, but still do -dM etc. as software
714 depends on this. Preprocessed output does occur if -MD, -MMD
715 or environment var dependency generation is used. */
716 cpp_opts->deps.style = (code == OPT_M ? DEPS_SYSTEM: DEPS_USER);
718 cpp_opts->inhibit_warnings = 1;
723 cpp_opts->deps.style = (code == OPT_MD ? DEPS_SYSTEM: DEPS_USER);
734 cpp_opts->deps.missing_files = true;
739 cpp_opts->deps.phony_targets = true;
745 defer_opt (code, arg);
749 flag_no_line_commands = 1;
760 warn_char_subscripts = on;
761 warn_missing_braces = on;
762 warn_parentheses = on;
763 warn_return_type = on;
764 warn_sequence_point = on; /* Was C only. */
765 warn_sign_compare = on; /* Was C++ only. */
767 warn_strict_aliasing = on;
769 /* Only warn about unknown pragmas that are not in system
771 warn_unknown_pragmas = on;
773 /* We save the value of warn_uninitialized, since if they put
774 -Wuninitialized on the command line, we need to generate a
775 warning about not using it without also specifying -O. */
776 if (warn_uninitialized != 1)
777 warn_uninitialized = (on ? 2 : 0);
779 if (c_language == clk_c)
780 /* We set this to 2 here, but 1 in -Wmain, so -ffreestanding
781 can turn it off only if it's not explicit. */
785 /* C++-specific warnings. */
786 warn_ctor_dtor_privacy = on;
789 warn_nontemplate_friend = on;
792 cpp_opts->warn_trigraphs = on;
793 cpp_opts->warn_comments = on;
794 cpp_opts->warn_num_sign_change = on;
795 cpp_opts->warn_multichar = on; /* Was C++ only. */
798 case OPT_Wbad_function_cast:
799 warn_bad_function_cast = on;
806 case OPT_Wchar_subscripts:
807 warn_char_subscripts = on;
812 cpp_opts->warn_comments = on;
815 case OPT_Wconversion:
816 warn_conversion = on;
819 case OPT_Wctor_dtor_privacy:
820 warn_ctor_dtor_privacy = on;
823 case OPT_Wdeprecated:
824 warn_deprecated = on;
825 cpp_opts->warn_deprecated = on;
828 case OPT_Wdiv_by_zero:
829 warn_div_by_zero = on;
836 case OPT_Wendif_labels:
837 cpp_opts->warn_endif_labels = on;
841 cpp_opts->warnings_are_errors = on;
844 case OPT_Werror_implicit_function_decl:
848 mesg_implicit_function_declaration = 2;
851 case OPT_Wfloat_equal:
852 warn_float_equal = on;
860 set_Wformat (atoi (arg));
863 case OPT_Wformat_extra_args:
864 warn_format_extra_args = on;
867 case OPT_Wformat_nonliteral:
868 warn_format_nonliteral = on;
871 case OPT_Wformat_security:
872 warn_format_security = on;
875 case OPT_Wformat_y2k:
876 warn_format_y2k = on;
879 case OPT_Wformat_zero_length:
880 warn_format_zero_length = on;
887 case OPT_Wimplicit_function_decl:
888 mesg_implicit_function_declaration = on;
891 case OPT_Wimplicit_int:
892 warn_implicit_int = on;
896 cpp_opts->warn_import = on;
899 case OPT_Winvalid_pch:
900 cpp_opts->warn_invalid_pch = on;
914 case OPT_Wmissing_braces:
915 warn_missing_braces = on;
918 case OPT_Wmissing_declarations:
919 warn_missing_declarations = on;
922 case OPT_Wmissing_format_attribute:
923 warn_missing_format_attribute = on;
926 case OPT_Wmissing_prototypes:
927 warn_missing_prototypes = on;
931 cpp_opts->warn_multichar = on;
934 case OPT_Wnested_externs:
935 warn_nested_externs = on;
938 case OPT_Wnon_template_friend:
939 warn_nontemplate_friend = on;
942 case OPT_Wnon_virtual_dtor:
950 case OPT_Wold_style_cast:
951 warn_old_style_cast = on;
954 case OPT_Woverloaded_virtual:
955 warn_overloaded_virtual = on;
958 case OPT_Wparentheses:
959 warn_parentheses = on;
962 case OPT_Wpmf_conversions:
966 case OPT_Wpointer_arith:
967 warn_pointer_arith = on;
978 case OPT_Wredundant_decls:
979 warn_redundant_decls = on;
986 case OPT_Wreturn_type:
987 warn_return_type = on;
990 case OPT_Wsequence_point:
991 warn_sequence_point = on;
994 case OPT_Wsign_compare:
995 warn_sign_compare = on;
998 case OPT_Wsign_promo:
999 warn_sign_promo = on;
1002 case OPT_Wstrict_prototypes:
1003 if (!on && c_language == clk_cplusplus)
1004 warning ("-Wno-strict-prototypes is not supported in C++");
1006 warn_strict_prototypes = on;
1013 case OPT_Wsystem_headers:
1014 cpp_opts->warn_system_headers = on;
1017 case OPT_Wtraditional:
1018 warn_traditional = on;
1019 cpp_opts->warn_traditional = on;
1022 case OPT_Wtrigraphs:
1023 cpp_opts->warn_trigraphs = on;
1026 case OPT_Wundeclared_selector:
1027 warn_undeclared_selector = on;
1031 cpp_opts->warn_undef = on;
1034 case OPT_Wunknown_pragmas:
1035 /* Set to greater than 1, so that even unknown pragmas in
1036 system headers will be warned about. */
1037 warn_unknown_pragmas = on * 2;
1040 case OPT_Wunused_macros:
1041 cpp_opts->warn_unused_macros = on;
1044 case OPT_Wwrite_strings:
1045 if (c_language == clk_c)
1046 flag_const_strings = on;
1048 warn_write_strings = on;
1052 if (c_language == clk_c)
1053 set_std_c89 (false, true);
1055 set_std_cxx98 (true);
1062 case OPT_fcond_mismatch:
1063 if (c_language == clk_c)
1065 flag_cond_mismatch = on;
1070 case OPT_fall_virtual:
1071 case OPT_fenum_int_equiv:
1072 case OPT_fguiding_decls:
1073 case OPT_fhonor_std:
1074 case OPT_fhuge_objects:
1075 case OPT_flabels_ok:
1076 case OPT_fname_mangling:
1078 case OPT_fnonnull_objects:
1080 case OPT_fstrict_prototype:
1081 case OPT_fthis_is_variable:
1082 case OPT_fvtable_thunks:
1084 warning ("switch \"%s\" is no longer supported", argv[0]);
1087 case OPT_fabi_version:
1088 flag_abi_version = read_integral_parameter (arg, argv[0], 1);
1091 case OPT_faccess_control:
1092 flag_access_control = on;
1095 case OPT_falt_external_templates:
1096 flag_alt_external_templates = on;
1098 flag_external_templates = true;
1100 warning ("switch \"%s\" is deprecated, please see documentation for details", argv[0]);
1108 flag_no_builtin = !on;
1115 disable_builtin_function (arg);
1118 case OPT_fdollars_in_identifiers:
1119 dollars_in_ident = on;
1123 if (!on || !dump_switch_p (argv[0] + strlen ("-f")))
1127 case OPT_ffreestanding:
1129 /* Fall through... */
1132 flag_no_builtin = !on;
1133 /* warn_main will be 2 if set by -Wall, 1 if set by -Wmain */
1134 if (!on && warn_main == 2)
1138 case OPT_fshort_double:
1139 flag_short_double = on;
1142 case OPT_fshort_enums:
1143 flag_short_enums = on;
1146 case OPT_fshort_wchar:
1147 flag_short_wchar = on;
1150 case OPT_fsigned_bitfields:
1151 flag_signed_bitfields = on;
1152 explicit_flag_signed_bitfields = 1;
1155 case OPT_fsigned_char:
1156 flag_signed_char = on;
1159 case OPT_funsigned_bitfields:
1160 flag_signed_bitfields = !on;
1161 explicit_flag_signed_bitfields = 1;
1164 case OPT_funsigned_char:
1165 flag_signed_char = !on;
1168 case OPT_fcheck_new:
1169 flag_check_new = on;
1172 case OPT_fconserve_space:
1173 flag_conserve_space = on;
1176 case OPT_fconst_strings:
1177 flag_const_strings = on;
1180 case OPT_fconstant_string_class:
1181 constant_string_class_name = arg;
1184 case OPT_fdefault_inline:
1185 flag_default_inline = on;
1188 case OPT_felide_constructors:
1189 flag_elide_constructors = on;
1192 case OPT_fenforce_eh_specs:
1193 flag_enforce_eh_specs = on;
1196 case OPT_fexternal_templates:
1197 flag_external_templates = on;
1200 case OPT_ffixed_form:
1201 case OPT_ffixed_line_length:
1202 /* Fortran front end options ignored when preprocessing only. */
1203 if (flag_preprocess_only)
1207 case OPT_ffor_scope:
1208 flag_new_for_scope = on;
1211 case OPT_fgnu_keywords:
1212 flag_no_gnu_keywords = !on;
1215 case OPT_fgnu_runtime:
1216 flag_next_runtime = !on;
1219 case OPT_fhandle_exceptions:
1220 warning ("-fhandle-exceptions has been renamed to -fexceptions (and is now on by default)");
1221 flag_exceptions = on;
1224 case OPT_fimplement_inlines:
1225 flag_implement_inlines = on;
1228 case OPT_fimplicit_inline_templates:
1229 flag_implicit_inline_templates = on;
1232 case OPT_fimplicit_templates:
1233 flag_implicit_templates = on;
1236 case OPT_fms_extensions:
1237 flag_ms_extensions = on;
1240 case OPT_fnext_runtime:
1241 flag_next_runtime = on;
1244 case OPT_fnonansi_builtins:
1245 flag_no_nonansi_builtin = !on;
1248 case OPT_foperator_names:
1249 cpp_opts->operator_names = on;
1252 case OPT_foptional_diags:
1253 flag_optional_diags = on;
1257 cpp_opts->restore_pch_deps = on;
1260 case OPT_fpermissive:
1261 flag_permissive = on;
1264 case OPT_fpreprocessed:
1265 cpp_opts->preprocessed = on;
1269 flag_use_repository = on;
1271 flag_implicit_templates = 0;
1278 case OPT_fshow_column:
1279 cpp_opts->show_column = on;
1283 flag_detailed_statistics = on;
1287 /* Don't recognize -fno-tabstop=. */
1291 /* It is documented that we silently ignore silly values. */
1294 long tabstop = strtol (arg, &endptr, 10);
1295 if (*endptr == '\0' && tabstop >= 1 && tabstop <= 100)
1296 cpp_opts->tabstop = tabstop;
1300 case OPT_ftemplate_depth:
1301 max_tinst_depth = read_integral_parameter (arg, argv[0], 0);
1304 case OPT_fvtable_gc:
1305 flag_vtable_gc = on;
1308 case OPT_fuse_cxa_atexit:
1309 flag_use_cxa_atexit = on;
1317 flag_gen_declaration = 1;
1321 add_path (xstrdup (arg), AFTER, 0);
1333 add_path (xstrdup (arg), SYSTEM, 0);
1336 case OPT_iwithprefix:
1337 add_prefixed_path (arg, SYSTEM);
1340 case OPT_iwithprefixbefore:
1341 add_prefixed_path (arg, BRACKET);
1345 cpp_set_lang (parse_in, CLK_ASM);
1356 case OPT_nostdincplusplus:
1357 std_cxx_inc = false;
1365 error ("output filename specified twice");
1370 /* We need to handle the -pedantic switches here, rather than in
1371 c_common_post_options, so that a subsequent -Wno-endif-labels
1372 is not overridden. */
1373 case OPT_pedantic_errors:
1374 cpp_opts->pedantic_errors = 1;
1377 cpp_opts->pedantic = 1;
1378 cpp_opts->warn_endif_labels = 1;
1381 case OPT_print_objc_runtime_info:
1382 print_struct_values = 1;
1386 cpp_opts->remap = 1;
1389 case OPT_std_cplusplus98:
1390 case OPT_std_gnuplusplus98:
1391 set_std_cxx98 (code == OPT_std_cplusplus98 /* ISO */);
1395 case OPT_std_iso9899_1990:
1396 case OPT_std_iso9899_199409:
1397 set_std_c89 (code == OPT_std_iso9899_199409 /* c94 */, true /* ISO */);
1401 set_std_c89 (false /* c94 */, false /* ISO */);
1406 case OPT_std_iso9899_1999:
1407 case OPT_std_iso9899_199x:
1408 set_std_c99 (true /* ISO */);
1413 set_std_c99 (false /* ISO */);
1417 cpp_opts->trigraphs = 1;
1420 case OPT_traditional_cpp:
1421 cpp_opts->traditional = 1;
1429 cpp_opts->inhibit_warnings = 1;
1443 /* Post-switch processing. */
1445 c_common_post_options ()
1447 /* Canonicalize the input and output filenames. */
1448 if (in_fname == NULL || !strcmp (in_fname, "-"))
1451 if (out_fname == NULL || !strcmp (out_fname, "-"))
1454 if (cpp_opts->deps.style == DEPS_NONE)
1455 check_deps_environment_vars ();
1457 handle_deferred_opts ();
1459 sanitize_cpp_opts ();
1461 register_include_chains (parse_in, sysroot, iprefix,
1462 std_inc, std_cxx_inc && c_language == clk_cplusplus,
1465 flag_inline_trees = 1;
1467 /* Use tree inlining if possible. Function instrumentation is only
1468 done in the RTL level, so we disable tree inlining. */
1469 if (! flag_instrument_function_entry_exit)
1471 if (!flag_no_inline)
1473 if (flag_inline_functions)
1475 flag_inline_trees = 2;
1476 flag_inline_functions = 0;
1480 /* Special format checking options don't work without -Wformat; warn if
1482 if (warn_format_y2k && !warn_format)
1483 warning ("-Wformat-y2k ignored without -Wformat");
1484 if (warn_format_extra_args && !warn_format)
1485 warning ("-Wformat-extra-args ignored without -Wformat");
1486 if (warn_format_zero_length && !warn_format)
1487 warning ("-Wformat-zero-length ignored without -Wformat");
1488 if (warn_format_nonliteral && !warn_format)
1489 warning ("-Wformat-nonliteral ignored without -Wformat");
1490 if (warn_format_security && !warn_format)
1491 warning ("-Wformat-security ignored without -Wformat");
1492 if (warn_missing_format_attribute && !warn_format)
1493 warning ("-Wmissing-format-attribute ignored without -Wformat");
1495 /* If an error has occurred in cpplib, note it so we fail
1497 errorcount += cpp_errors (parse_in);
1499 return flag_preprocess_only;
1502 /* Front end initialization common to C, ObjC and C++. */
1504 c_common_init (filename)
1505 const char *filename;
1507 /* Set up preprocessor arithmetic. Must be done after call to
1508 c_common_nodes_and_builtins for type nodes to be good. */
1509 cpp_opts->precision = TYPE_PRECISION (intmax_type_node);
1510 cpp_opts->char_precision = TYPE_PRECISION (char_type_node);
1511 cpp_opts->int_precision = TYPE_PRECISION (integer_type_node);
1512 cpp_opts->wchar_precision = TYPE_PRECISION (wchar_type_node);
1513 cpp_opts->unsigned_wchar = TREE_UNSIGNED (wchar_type_node);
1515 /* Register preprocessor built-ins before calls to
1517 cpp_get_callbacks (parse_in)->register_builtins = cb_register_builtins;
1519 if (flag_preprocess_only)
1521 /* Open the output now. We must do so even if flag_no_output is
1522 on, because there may be other output than from the actual
1523 preprocessing (e.g. from -dM). */
1524 if (out_fname[0] == '\0')
1525 out_stream = stdout;
1527 out_stream = fopen (out_fname, "w");
1529 if (out_stream == NULL)
1530 fatal_io_error ("opening output file %s", out_fname);
1532 /* Preprocess the input file to out_stream. */
1533 preprocess_file (parse_in, in_fname, out_stream);
1535 /* Exit quickly in toplev.c. */
1541 /* Start it at 0. */
1544 /* NOTE: we use in_fname here, not the one supplied. */
1545 filename = cpp_read_main_file (parse_in, in_fname, ident_hash);
1547 /* Has to wait until now so that cpplib has its hash table. */
1553 /* Common finish hook for the C, ObjC and C++ front ends. */
1557 FILE *deps_stream = NULL;
1559 if (cpp_opts->deps.style != DEPS_NONE)
1561 /* If -M or -MM was seen without -MF, default output to the
1564 deps_stream = out_stream;
1567 deps_stream = fopen (deps_file, deps_append ? "a": "w");
1569 fatal_io_error ("opening dependency file %s", deps_file);
1573 /* For performance, avoid tearing down cpplib's internal structures
1574 with cpp_destroy (). */
1575 errorcount += cpp_finish (parse_in, deps_stream);
1577 if (deps_stream && deps_stream != out_stream
1578 && (ferror (deps_stream) || fclose (deps_stream)))
1579 fatal_io_error ("closing dependency file %s", deps_file);
1581 if (out_stream && (ferror (out_stream) || fclose (out_stream)))
1582 fatal_io_error ("when writing output to %s", out_fname);
1585 /* Either of two environment variables can specify output of
1586 dependencies. Their value is either "OUTPUT_FILE" or "OUTPUT_FILE
1587 DEPS_TARGET", where OUTPUT_FILE is the file to write deps info to
1588 and DEPS_TARGET is the target to mention in the deps. They also
1589 result in dependency information being appended to the output file
1590 rather than overwriting it, and like Sun's compiler
1591 SUNPRO_DEPENDENCIES suppresses the dependency on the main file. */
1593 check_deps_environment_vars ()
1597 GET_ENVIRONMENT (spec, "DEPENDENCIES_OUTPUT");
1599 cpp_opts->deps.style = DEPS_USER;
1602 GET_ENVIRONMENT (spec, "SUNPRO_DEPENDENCIES");
1605 cpp_opts->deps.style = DEPS_SYSTEM;
1606 cpp_opts->deps.ignore_main_file = true;
1612 /* Find the space before the DEPS_TARGET, if there is one. */
1613 char *s = strchr (spec, ' ');
1616 /* Let the caller perform MAKE quoting. */
1617 defer_opt (OPT_MT, s + 1);
1621 /* Command line -MF overrides environment variables and default. */
1629 /* Handle deferred command line switches. */
1631 handle_deferred_opts ()
1635 for (i = 0; i < deferred_count; i++)
1637 struct deferred_opt *opt = &deferred_opts[i];
1643 cpp_add_dependency_target (parse_in, opt->arg, opt->code == OPT_MQ);
1651 free (deferred_opts);
1654 /* These settings are appropriate for GCC, but not necessarily so for
1655 cpplib as a library. */
1657 sanitize_cpp_opts ()
1659 /* If we don't know what style of dependencies to output, complain
1660 if any other dependency switches have been given. */
1661 if (deps_seen && cpp_opts->deps.style == DEPS_NONE)
1662 error ("to generate dependencies you must specify either -M or -MM");
1664 /* -dM and dependencies suppress normal output; do it here so that
1665 the last -d[MDN] switch overrides earlier ones. */
1666 if (flag_dump_macros == 'M')
1669 /* Disable -dD, -dN and -dI if normal output is suppressed. Allow
1670 -dM since at least glibc relies on -M -dM to work. */
1673 if (flag_dump_macros != 'M')
1674 flag_dump_macros = 0;
1675 flag_dump_includes = 0;
1678 cpp_opts->unsigned_char = !flag_signed_char;
1679 cpp_opts->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;
1681 /* We want -Wno-long-long to override -pedantic -std=non-c99
1682 and/or -Wtraditional, whatever the ordering. */
1683 cpp_opts->warn_long_long
1684 = warn_long_long && ((!flag_isoc99 && pedantic) || warn_traditional);
1687 /* Add include path with a prefix at the front of its name. */
1689 add_prefixed_path (suffix, chain)
1695 prefix = iprefix ? iprefix: cpp_GCC_INCLUDE_DIR;
1696 add_path (concat (prefix, suffix), chain, 0);
1699 /* Set the C 89 standard (with 1994 amendments if C94, without GNU
1700 extensions if ISO). There is no concept of gnu94. */
1702 set_std_c89 (c94, iso)
1705 cpp_set_lang (parse_in, c94 ? CLK_STDC94: iso ? CLK_STDC89: CLK_GNUC89);
1708 flag_no_gnu_keywords = iso;
1709 flag_no_nonansi_builtin = iso;
1710 flag_noniso_default_format_attributes = !iso;
1713 flag_writable_strings = 0;
1716 /* Set the C 99 standard (without GNU extensions if ISO). */
1721 cpp_set_lang (parse_in, iso ? CLK_STDC99: CLK_GNUC99);
1723 flag_no_nonansi_builtin = iso;
1724 flag_noniso_default_format_attributes = !iso;
1728 flag_writable_strings = 0;
1731 /* Set the C++ 98 standard (without GNU extensions if ISO). */
1736 cpp_set_lang (parse_in, iso ? CLK_CXX98: CLK_GNUCXX);
1737 flag_no_gnu_keywords = iso;
1738 flag_no_nonansi_builtin = iso;
1739 flag_noniso_default_format_attributes = !iso;
1743 /* Handle setting implicit to ON. */
1749 warn_implicit_int = on;
1752 if (mesg_implicit_function_declaration != 2)
1753 mesg_implicit_function_declaration = 1;
1756 mesg_implicit_function_declaration = 0;
1759 /* Args to -d specify what to dump. Silently ignore
1760 unrecognized options; they may be aimed at toplev.c. */
1767 while ((c = *arg++) != '\0')
1770 case 'M': /* Dump macros only. */
1771 case 'N': /* Dump names. */
1772 case 'D': /* Dump definitions. */
1773 flag_dump_macros = c;
1777 flag_dump_includes = 1;
1782 /* Write a slash-separated list of languages in FLAGS to BUF. */
1784 write_langs (buf, flags)
1789 if (flags & CL_C_ONLY)
1791 if (flags & CL_OBJC_ONLY)
1795 strcat (buf, "ObjC");
1797 if (flags & CL_CXX_ONLY)
1801 strcat (buf, "C++");
1805 /* Complain that switch OPT_INDEX does not apply to this front end. */
1807 complain_wrong_lang (opt_index)
1810 char ok_langs[60], bad_langs[60];
1811 int ok_flags = cl_options[opt_index].flags;
1813 write_langs (ok_langs, ok_flags);
1814 write_langs (bad_langs, ~ok_flags);
1815 warning ("\"-%s\" is valid for %s but not for %s",
1816 cl_options[opt_index].opt_text, ok_langs, bad_langs);
1819 /* Handle --help output. */
1823 /* To keep the lines from getting too long for some compilers, limit
1824 to about 500 characters (6 lines) per chunk. */
1827 -include <file> Include the contents of <file> before other files\n\
1828 -imacros <file> Accept definition of macros in <file>\n\
1829 -iprefix <path> Specify <path> as a prefix for next two options\n\
1830 -iwithprefix <dir> Add <dir> to the end of the system include path\n\
1831 -iwithprefixbefore <dir> Add <dir> to the end of the main include path\n\
1832 -isystem <dir> Add <dir> to the start of the system include path\n\
1835 -idirafter <dir> Add <dir> to the end of the system include path\n\
1836 -I <dir> Add <dir> to the end of the main include path\n\
1837 -I- Fine-grained include path control; see info docs\n\
1838 -nostdinc Do not search system include directories\n\
1839 (dirs specified with -isystem will still be used)\n\
1840 -nostdinc++ Do not search system include directories for C++\n\
1841 -o <file> Put output into <file>\n\
1844 -trigraphs Support ISO C trigraphs\n\
1845 -std=<std name> Specify the conformance standard; one of:\n\
1846 gnu89, gnu99, c89, c99, iso9899:1990,\n\
1847 iso9899:199409, iso9899:1999, c++98\n\
1848 -w Inhibit warning messages\n\
1849 -W[no-]trigraphs Warn if trigraphs are encountered\n\
1850 -W[no-]comment{s} Warn if one comment starts inside another\n\
1853 -W[no-]traditional Warn about features not present in traditional C\n\
1854 -W[no-]undef Warn if an undefined macro is used by #if\n\
1855 -W[no-]import Warn about the use of the #import directive\n\
1858 -W[no-]error Treat all warnings as errors\n\
1859 -W[no-]system-headers Do not suppress warnings from system headers\n\
1860 -W[no-]all Enable most preprocessor warnings\n\
1863 -M Generate make dependencies\n\
1864 -MM As -M, but ignore system header files\n\
1865 -MD Generate make dependencies and compile\n\
1866 -MMD As -MD, but ignore system header files\n\
1867 -MF <file> Write dependency output to the given file\n\
1868 -MG Treat missing header file as generated files\n\
1871 -MP Generate phony targets for all headers\n\
1872 -MQ <target> Add a MAKE-quoted target\n\
1873 -MT <target> Add an unquoted target\n\
1876 -D<macro> Define a <macro> with string '1' as its value\n\
1877 -D<macro>=<val> Define a <macro> with <val> as its value\n\
1878 -A<question>=<answer> Assert the <answer> to <question>\n\
1879 -A-<question>=<answer> Disable the <answer> to <question>\n\
1880 -U<macro> Undefine <macro> \n\
1881 -v Display the version number\n\
1884 -H Print the name of header files as they are used\n\
1885 -C Do not discard comments\n\
1886 -dM Display a list of macro definitions active at end\n\
1887 -dD Preserve macro definitions in output\n\
1888 -dN As -dD except that only the names are preserved\n\
1889 -dI Include #include directives in the output\n\
1892 -f[no-]preprocessed Treat the input file as already preprocessed\n\
1893 -ftabstop=<number> Distance between tab stops for column reporting\n\
1894 -isysroot <dir> Set <dir> to be the system root directory\n\
1895 -P Do not generate #line directives\n\
1896 -remap Remap file names when including files\n\
1897 --help Display this information\n\