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
42 static int saved_lineno
;
45 static cpp_options
*cpp_opts
;
48 static const char *in_fname
;
50 /* Filename and stream for preprocessed output. */
51 static const char *out_fname
;
52 static FILE *out_stream
;
54 /* Append dependencies to deps_file. */
55 static bool deps_append
;
57 /* If dependency switches (-MF etc.) have been given. */
58 static bool deps_seen
;
63 /* Dependency output file. */
64 static const char *deps_file
;
66 /* The prefix given by -iprefix, if any. */
67 static const char *iprefix
;
69 /* The system root, if any. Overridden by -isysroot. */
70 static const char *sysroot
= TARGET_SYSTEM_ROOT
;
72 /* Zero disables all standard directories for headers. */
73 static bool std_inc
= true;
75 /* Zero disables the C++-specific standard directories for headers. */
76 static bool std_cxx_inc
= true;
78 /* If the quote chain has been split by -I-. */
79 static bool quote_chain_split
;
81 /* Number of deferred options, deferred options array size. */
82 static size_t deferred_count
, deferred_size
;
84 static void missing_arg
PARAMS ((size_t));
85 static size_t find_opt
PARAMS ((const char *, int));
86 static void set_Wimplicit
PARAMS ((int));
87 static void complain_wrong_lang
PARAMS ((size_t));
88 static void write_langs
PARAMS ((char *, int));
89 static void print_help
PARAMS ((void));
90 static void handle_OPT_d
PARAMS ((const char *));
91 static void set_std_cxx98
PARAMS ((int));
92 static void set_std_c89
PARAMS ((int, int));
93 static void set_std_c99
PARAMS ((int));
94 static void check_deps_environment_vars
PARAMS ((void));
95 static void handle_deferred_opts
PARAMS ((void));
96 static void sanitize_cpp_opts
PARAMS ((void));
97 static void add_prefixed_path
PARAMS ((const char *, size_t));
99 #ifndef STDC_0_IN_SYSTEM_HEADERS
100 #define STDC_0_IN_SYSTEM_HEADERS 0
103 #define CL_C_ONLY (1 << 0) /* Only C. */
104 #define CL_OBJC_ONLY (1 << 1) /* Only ObjC. */
105 #define CL_CXX_ONLY (1 << 2) /* Only C++. */
106 #define CL_OBJCXX_ONLY (1 << 3) /* Only ObjC++. */
107 #define CL_JOINED (1 << 4) /* If takes joined argument. */
108 #define CL_SEPARATE (1 << 5) /* If takes a separate argument. */
110 #define CL_ARG (CL_JOINED | CL_SEPARATE)
111 #define CL_C (CL_C_ONLY | CL_OBJC_ONLY)
112 #define CL_OBJC (CL_OBJC_ONLY | CL_OBJCXX_ONLY)
113 #define CL_CXX (CL_CXX_ONLY | CL_OBJCXX_ONLY)
114 #define CL_ALL (CL_C | CL_CXX)
116 /* This is the list of all command line options, with the leading "-"
117 removed. It must be sorted in ASCII collating order. All options
118 beginning with "f" or "W" are implicitly assumed to take a "no-"
119 form; this form should not be listed. The variable "on" is true if
120 the positive form is given, otherwise it is false. If you don't
121 want to allow a "no-" form, your handler should reject "on" being
122 false by returning zero. See, for example, the handling of
125 If the user gives an option to a front end that doesn't support it,
126 an error is output, mentioning which front ends the option is valid
127 for. If you don't want this, you must accept it for all front
128 ends, and test for the front end in the option handler. See, for
129 example, the handling of -Wno-strict-prototypes for C++.
131 If you request an argument with CL_JOINED, CL_SEPARATE or their
132 combination CL_ARG, it is stored in the variable "arg", which is
133 guaranteed to be non-NULL and to not be an empty string. It points
134 to the argument either within the argv[] vector or within one of
135 that vector's strings, and so the text is permanent and copies need
136 not be made. Be sure to add an error message in missing_arg() if
137 the default is not appropriate. */
139 #define COMMAND_LINE_OPTIONS \
140 OPT("-help", CL_ALL, OPT__help) \
141 OPT("-output-pch=", CL_ALL | CL_ARG, OPT__output_pch) \
142 OPT("C", CL_ALL, OPT_C) \
143 OPT("CC", CL_ALL, OPT_CC) \
144 OPT("E", CL_ALL, OPT_E) \
145 OPT("H", CL_ALL, OPT_H) \
146 OPT("I", CL_ALL | CL_ARG, OPT_I) \
147 OPT("M", CL_ALL, OPT_M) \
148 OPT("MD", CL_ALL | CL_SEPARATE, OPT_MD) \
149 OPT("MF", CL_ALL | CL_ARG, OPT_MF) \
150 OPT("MG", CL_ALL, OPT_MG) \
151 OPT("MM", CL_ALL, OPT_MM) \
152 OPT("MMD", CL_ALL | CL_SEPARATE, OPT_MMD) \
153 OPT("MP", CL_ALL, OPT_MP) \
154 OPT("MQ", CL_ALL | CL_ARG, OPT_MQ) \
155 OPT("MT", CL_ALL | CL_ARG, OPT_MT) \
156 OPT("P", CL_ALL, OPT_P) \
157 OPT("Wabi", CL_CXX, OPT_Wabi) \
158 OPT("Wall", CL_ALL, OPT_Wall) \
159 OPT("Wbad-function-cast", CL_C, OPT_Wbad_function_cast) \
160 OPT("Wcast-qual", CL_ALL, OPT_Wcast_qual) \
161 OPT("Wchar-subscripts", CL_ALL, OPT_Wchar_subscripts) \
162 OPT("Wcomment", CL_ALL, OPT_Wcomment) \
163 OPT("Wcomments", CL_ALL, OPT_Wcomments) \
164 OPT("Wconversion", CL_ALL, OPT_Wconversion) \
165 OPT("Wctor-dtor-privacy", CL_CXX, OPT_Wctor_dtor_privacy) \
166 OPT("Wdeprecated", CL_CXX, OPT_Wdeprecated) \
167 OPT("Wdiv-by-zero", CL_C, OPT_Wdiv_by_zero) \
168 OPT("Weffc++", CL_CXX, OPT_Weffcxx) \
169 OPT("Wendif-labels", CL_ALL, OPT_Wendif_labels) \
170 OPT("Werror", CL_ALL, OPT_Werror) \
171 OPT("Werror-implicit-function-declaration", \
172 CL_C, OPT_Werror_implicit_function_decl) \
173 OPT("Wfloat-equal", CL_ALL, OPT_Wfloat_equal) \
174 OPT("Wformat", CL_ALL, OPT_Wformat) \
175 OPT("Wformat-extra-args", CL_ALL, OPT_Wformat_extra_args) \
176 OPT("Wformat-nonliteral", CL_ALL, OPT_Wformat_nonliteral) \
177 OPT("Wformat-security", CL_ALL, OPT_Wformat_security) \
178 OPT("Wformat-y2k", CL_ALL, OPT_Wformat_y2k) \
179 OPT("Wformat-zero-length", CL_C, OPT_Wformat_zero_length) \
180 OPT("Wformat=", CL_ALL | CL_JOINED, OPT_Wformat_eq) \
181 OPT("Wimplicit", CL_ALL, OPT_Wimplicit) \
182 OPT("Wimplicit-function-declaration", CL_C, OPT_Wimplicit_function_decl) \
183 OPT("Wimplicit-int", CL_C, OPT_Wimplicit_int) \
184 OPT("Wimport", CL_ALL, OPT_Wimport) \
185 OPT("Winvalid-pch", CL_ALL, OPT_Winvalid_pch) \
186 OPT("Wlong-long", CL_ALL, OPT_Wlong_long) \
187 OPT("Wmain", CL_C, OPT_Wmain) \
188 OPT("Wmissing-braces", CL_ALL, OPT_Wmissing_braces) \
189 OPT("Wmissing-declarations", CL_C, OPT_Wmissing_declarations) \
190 OPT("Wmissing-format-attribute",CL_ALL, OPT_Wmissing_format_attribute) \
191 OPT("Wmissing-prototypes", CL_ALL, OPT_Wmissing_prototypes) \
192 OPT("Wmultichar", CL_ALL, OPT_Wmultichar) \
193 OPT("Wnested-externs", CL_C, OPT_Wnested_externs) \
194 OPT("Wnon-template-friend", CL_CXX, OPT_Wnon_template_friend) \
195 OPT("Wnon-virtual-dtor", CL_CXX, OPT_Wnon_virtual_dtor) \
196 OPT("Wnonnull", CL_C, OPT_Wnonnull) \
197 OPT("Wold-style-cast", CL_CXX, OPT_Wold_style_cast) \
198 OPT("Woverloaded-virtual", CL_CXX, OPT_Woverloaded_virtual) \
199 OPT("Wparentheses", CL_ALL, OPT_Wparentheses) \
200 OPT("Wpmf-conversions", CL_CXX, OPT_Wpmf_conversions) \
201 OPT("Wpointer-arith", CL_ALL, OPT_Wpointer_arith) \
202 OPT("Wprotocol", CL_OBJC, OPT_Wprotocol) \
203 OPT("Wredundant-decls", CL_ALL, OPT_Wredundant_decls) \
204 OPT("Wreorder", CL_CXX, OPT_Wreorder) \
205 OPT("Wreturn-type", CL_ALL, OPT_Wreturn_type) \
206 OPT("Wselector", CL_OBJC, OPT_Wselector) \
207 OPT("Wsequence-point", CL_C, OPT_Wsequence_point) \
208 OPT("Wsign-compare", CL_ALL, OPT_Wsign_compare) \
209 OPT("Wsign-promo", CL_CXX, OPT_Wsign_promo) \
210 OPT("Wstrict-prototypes", CL_ALL, OPT_Wstrict_prototypes) \
211 OPT("Wsynth", CL_CXX, OPT_Wsynth) \
212 OPT("Wsystem-headers", CL_ALL, OPT_Wsystem_headers) \
213 OPT("Wtraditional", CL_C, OPT_Wtraditional) \
214 OPT("Wtrigraphs", CL_ALL, OPT_Wtrigraphs) \
215 OPT("Wundeclared-selector", CL_OBJC, OPT_Wundeclared_selector) \
216 OPT("Wundef", CL_ALL, OPT_Wundef) \
217 OPT("Wunknown-pragmas", CL_ALL, OPT_Wunknown_pragmas) \
218 OPT("Wunused-macros", CL_ALL, OPT_Wunused_macros) \
219 OPT("Wwrite-strings", CL_ALL, OPT_Wwrite_strings) \
220 OPT("ansi", CL_ALL, OPT_ansi) \
221 OPT("d", CL_ALL | CL_JOINED, OPT_d) \
222 OPT("fabi-version=", CL_CXX | CL_JOINED, OPT_fabi_version) \
223 OPT("faccess-control", CL_CXX, OPT_faccess_control) \
224 OPT("fall-virtual", CL_CXX, OPT_fall_virtual) \
225 OPT("falt-external-templates",CL_CXX, OPT_falt_external_templates) \
226 OPT("fasm", CL_ALL, OPT_fasm) \
227 OPT("fbuiltin", CL_ALL, OPT_fbuiltin) \
228 OPT("fbuiltin-", CL_ALL | CL_JOINED, OPT_fbuiltin_) \
229 OPT("fcheck-new", CL_CXX, OPT_fcheck_new) \
230 OPT("fcond-mismatch", CL_ALL, OPT_fcond_mismatch) \
231 OPT("fconserve-space", CL_CXX, OPT_fconserve_space) \
232 OPT("fconst-strings", CL_CXX, OPT_fconst_strings) \
233 OPT("fconstant-string-class=", CL_OBJC | CL_JOINED, \
234 OPT_fconstant_string_class) \
235 OPT("fdefault-inline", CL_CXX, OPT_fdefault_inline) \
236 OPT("fdollars-in-identifiers",CL_ALL, OPT_fdollars_in_identifiers) \
237 OPT("fdump-", CL_ALL | CL_JOINED, OPT_fdump) \
238 OPT("felide-constructors", CL_CXX, OPT_felide_constructors) \
239 OPT("fenforce-eh-specs", CL_CXX, OPT_fenforce_eh_specs) \
240 OPT("fenum-int-equiv", CL_CXX, OPT_fenum_int_equiv) \
241 OPT("fexternal-templates", CL_CXX, OPT_fexternal_templates) \
242 OPT("ffixed-form", CL_C, OPT_ffixed_form) \
243 OPT("ffixed-line-length-", CL_C | CL_JOINED, OPT_ffixed_line_length) \
244 OPT("ffor-scope", CL_CXX, OPT_ffor_scope) \
245 OPT("ffreestanding", CL_C, OPT_ffreestanding) \
246 OPT("fgnu-keywords", CL_CXX, OPT_fgnu_keywords) \
247 OPT("fgnu-runtime", CL_OBJC, OPT_fgnu_runtime) \
248 OPT("fguiding-decls", CL_CXX, OPT_fguiding_decls) \
249 OPT("fhandle-exceptions", CL_CXX, OPT_fhandle_exceptions) \
250 OPT("fhonor-std", CL_CXX, OPT_fhonor_std) \
251 OPT("fhosted", CL_C, OPT_fhosted) \
252 OPT("fhuge-objects", CL_CXX, OPT_fhuge_objects) \
253 OPT("fimplement-inlines", CL_CXX, OPT_fimplement_inlines) \
254 OPT("fimplicit-inline-templates", CL_CXX, OPT_fimplicit_inline_templates) \
255 OPT("fimplicit-templates", CL_CXX, OPT_fimplicit_templates) \
256 OPT("flabels-ok", CL_CXX, OPT_flabels_ok) \
257 OPT("fms-extensions", CL_ALL, OPT_fms_extensions) \
258 OPT("fname-mangling-version-",CL_CXX | CL_JOINED, OPT_fname_mangling) \
259 OPT("fnew-abi", CL_CXX, OPT_fnew_abi) \
260 OPT("fnext-runtime", CL_OBJC, OPT_fnext_runtime) \
261 OPT("fnonansi-builtins", CL_CXX, OPT_fnonansi_builtins) \
262 OPT("fnonnull-objects", CL_CXX, OPT_fnonnull_objects) \
263 OPT("foperator-names", CL_CXX, OPT_foperator_names) \
264 OPT("foptional-diags", CL_CXX, OPT_foptional_diags) \
265 OPT("fpch-deps", CL_ALL, OPT_fpch_deps) \
266 OPT("fpermissive", CL_CXX, OPT_fpermissive) \
267 OPT("fpreprocessed", CL_ALL, OPT_fpreprocessed) \
268 OPT("frepo", CL_CXX, OPT_frepo) \
269 OPT("frtti", CL_CXX, OPT_frtti) \
270 OPT("fshort-double", CL_ALL, OPT_fshort_double) \
271 OPT("fshort-enums", CL_ALL, OPT_fshort_enums) \
272 OPT("fshort-wchar", CL_ALL, OPT_fshort_wchar) \
273 OPT("fshow-column", CL_ALL, OPT_fshow_column) \
274 OPT("fsigned-bitfields", CL_ALL, OPT_fsigned_bitfields) \
275 OPT("fsigned-char", CL_ALL, OPT_fsigned_char) \
276 OPT("fsquangle", CL_CXX, OPT_fsquangle) \
277 OPT("fstats", CL_CXX, OPT_fstats) \
278 OPT("fstrict-prototype", CL_CXX, OPT_fstrict_prototype) \
279 OPT("ftabstop=", CL_ALL | CL_JOINED, OPT_ftabstop) \
280 OPT("ftemplate-depth-", CL_CXX | CL_JOINED, OPT_ftemplate_depth) \
281 OPT("fthis-is-variable", CL_CXX, OPT_fthis_is_variable) \
282 OPT("funsigned-bitfields", CL_ALL, OPT_funsigned_bitfields) \
283 OPT("funsigned-char", CL_ALL, OPT_funsigned_char) \
284 OPT("fuse-cxa-atexit", CL_CXX, OPT_fuse_cxa_atexit) \
285 OPT("fvtable-gc", CL_CXX, OPT_fvtable_gc) \
286 OPT("fvtable-thunks", CL_CXX, OPT_fvtable_thunks) \
287 OPT("fweak", CL_CXX, OPT_fweak) \
288 OPT("fxref", CL_CXX, OPT_fxref) \
289 OPT("gen-decls", CL_OBJC, OPT_gen_decls) \
290 OPT("idirafter", CL_ALL | CL_ARG, OPT_idirafter) \
291 OPT("iprefix", CL_ALL | CL_ARG, OPT_iprefix) \
292 OPT("isysroot", CL_ALL | CL_ARG, OPT_isysroot) \
293 OPT("isystem", CL_ALL | CL_ARG, OPT_isystem) \
294 OPT("iwithprefix", CL_ALL | CL_ARG, OPT_iwithprefix) \
295 OPT("iwithprefixbefore", CL_ALL | CL_ARG, OPT_iwithprefixbefore) \
296 OPT("lang-asm", CL_C_ONLY, OPT_lang_asm) \
297 OPT("lang-objc", CL_ALL, OPT_lang_objc) \
298 OPT("nostdinc", CL_ALL, OPT_nostdinc) \
299 OPT("nostdinc++", CL_ALL, OPT_nostdincplusplus) \
300 OPT("o", CL_ALL | CL_ARG, OPT_o) \
301 OPT("pedantic", CL_ALL, OPT_pedantic) \
302 OPT("pedantic-errors", CL_ALL, OPT_pedantic_errors) \
303 OPT("print-objc-runtime-info", CL_OBJC, OPT_print_objc_runtime_info) \
304 OPT("remap", CL_ALL, OPT_remap) \
305 OPT("std=c++98", CL_CXX, OPT_std_cplusplus98) \
306 OPT("std=c89", CL_C, OPT_std_c89) \
307 OPT("std=c99", CL_C, OPT_std_c99) \
308 OPT("std=c9x", CL_C, OPT_std_c9x) \
309 OPT("std=gnu++98", CL_CXX, OPT_std_gnuplusplus98) \
310 OPT("std=gnu89", CL_C, OPT_std_gnu89) \
311 OPT("std=gnu99", CL_C, OPT_std_gnu99) \
312 OPT("std=gnu9x", CL_C, OPT_std_gnu9x) \
313 OPT("std=iso9899:1990", CL_C, OPT_std_iso9899_1990) \
314 OPT("std=iso9899:199409", CL_C, OPT_std_iso9899_199409) \
315 OPT("std=iso9899:1999", CL_C, OPT_std_iso9899_1999) \
316 OPT("std=iso9899:199x", CL_C, OPT_std_iso9899_199x) \
317 OPT("traditional-cpp", CL_ALL, OPT_traditional_cpp) \
318 OPT("trigraphs", CL_ALL, OPT_trigraphs) \
319 OPT("undef", CL_ALL, OPT_undef) \
320 OPT("v", CL_ALL, OPT_v) \
321 OPT("w", CL_ALL, OPT_w)
323 #define OPT(text, flags, code) code,
333 const char *opt_text
;
334 unsigned char opt_len
;
336 ENUM_BITFIELD (opt_code
) opt_code
: 2 * CHAR_BIT
;
339 #define OPT(text, flags, code) { text, sizeof(text) - 1, flags, code },
341 static struct cl_option cl_options
[] =
343 static const struct cl_option cl_options
[] =
349 #undef COMMAND_LINE_OPTIONS
351 /* Holds switches parsed by c_common_decode_option (), but whose
352 handling is deferred to c_common_post_options (). */
353 static void defer_opt
PARAMS ((enum opt_code
, const char *));
354 static struct deferred_opt
362 static int opt_comp
PARAMS ((const void *, const void *));
364 /* Run-time sorting of options array. */
369 return strcmp (((struct cl_option
*) p1
)->opt_text
,
370 ((struct cl_option
*) p2
)->opt_text
);
374 /* Complain that switch OPT_INDEX expects an argument but none was
377 missing_arg (opt_index
)
380 const char *opt_text
= cl_options
[opt_index
].opt_text
;
382 switch (cl_options
[opt_index
].opt_code
)
384 case OPT__output_pch
:
387 case OPT_fabi_version
:
390 case OPT_fname_mangling
:
392 case OPT_ftemplate_depth
:
394 case OPT_iwithprefix
:
395 case OPT_iwithprefixbefore
:
397 error ("missing argument to \"-%s\"", opt_text
);
400 case OPT_fconstant_string_class
:
401 error ("no class name specified with \"-%s\"", opt_text
);
408 error ("missing path after \"-%s\"", opt_text
);
415 error ("missing filename after \"-%s\"", opt_text
);
420 error ("missing target after \"-%s\"", opt_text
);
425 /* Perform a binary search to find which option the command-line INPUT
426 matches. Returns its index in the option array, and N_OPTS on
429 Complications arise since some options can be suffixed with an
430 argument, and multiple complete matches can occur, e.g. -pedantic
431 and -pedantic-errors. Also, some options are only accepted by some
432 languages. If a switch matches for a different language and
433 doesn't match any alternatives for the true front end, the index of
434 the matched switch is returned anyway. The caller should check for
437 find_opt (input
, lang_flag
)
443 size_t result
= N_OPTS
;
453 opt_len
= cl_options
[md
].opt_len
;
454 comp
= strncmp (input
, cl_options
[md
].opt_text
, opt_len
);
462 /* The switch matches. It it an exact match? */
463 if (input
[opt_len
] == '\0')
469 /* If the switch takes no arguments this is not a proper
470 match, so we continue the search (e.g. input="stdc++"
471 match was "stdc"). */
472 if (!(cl_options
[md
].flags
& CL_JOINED
))
475 /* Is this switch valid for this front end? */
476 if (!(cl_options
[md
].flags
& lang_flag
))
478 /* If subsequently we don't find a better match,
479 return this and let the caller report it as a bad
485 /* Two scenarios remain: we have the switch's argument,
486 or we match a longer option. This can happen with
487 -iwithprefix and -withprefixbefore. The longest
488 possible option match succeeds.
490 Scan forwards, and return an exact match. Otherwise
491 return the longest valid option-accepting match (mx).
492 This loops at most twice with current options. */
494 for (md
= md
+ 1; md
< (size_t) N_OPTS
; md
++)
496 opt_len
= cl_options
[md
].opt_len
;
497 if (strncmp (input
, cl_options
[md
].opt_text
, opt_len
))
499 if (input
[opt_len
] == '\0')
501 if (cl_options
[md
].flags
& lang_flag
502 && cl_options
[md
].flags
& CL_JOINED
)
514 /* Defer option CODE with argument ARG. */
516 defer_opt (code
, arg
)
520 /* FIXME: this should be in c_common_init_options, which should take
524 extern int save_argc
;
525 deferred_size
= save_argc
;
526 deferred_opts
= (struct deferred_opt
*)
527 xmalloc (deferred_size
* sizeof (struct deferred_opt
));
530 if (deferred_count
== deferred_size
)
533 deferred_opts
[deferred_count
].code
= code
;
534 deferred_opts
[deferred_count
].arg
= arg
;
538 /* Common initialization before parsing options. */
540 c_common_init_options (lang
)
541 enum c_language_kind lang
;
544 /* For non-ASCII hosts, the cl_options array needs to be sorted at
546 qsort (cl_options
, N_OPTS
, sizeof (struct cl_option
), opt_comp
);
552 for (i
= 1; i
< N_OPTS
; i
++)
553 if (strcmp (cl_options
[i
- 1].opt_text
, cl_options
[i
].opt_text
) >= 0)
554 error ("options array incorrectly sorted: %s is before %s",
555 cl_options
[i
- 1].opt_text
, cl_options
[i
].opt_text
);
560 parse_in
= cpp_create_reader (lang
== clk_c
? CLK_GNUC89
: CLK_GNUCXX
);
561 cpp_opts
= cpp_get_options (parse_in
);
565 flag_const_strings
= (lang
== clk_cplusplus
);
566 warn_pointer_arith
= (lang
== clk_cplusplus
);
568 warn_sign_compare
= -1;
571 /* Handle one command-line option in (argc, argv).
572 Can be called multiple times, to handle multiple sets of options.
573 Returns number of strings consumed. */
575 c_common_decode_option (argc
, argv
)
579 static const int lang_flags
[] = {CL_C_ONLY
, CL_C
, CL_CXX_ONLY
, CL_CXX
};
581 const char *opt
, *arg
= 0;
584 int result
, lang_flag
;
585 const struct cl_option
*option
;
590 /* Interpret "-" or a non-switch as a file name. */
591 if (opt
[0] != '-' || opt
[1] == '\0')
599 error ("too many filenames given. Type %s --help for usage",
607 /* Drop the "no-" from negative switches. */
608 if ((opt
[1] == 'W' || opt
[1] == 'f')
609 && opt
[2] == 'n' && opt
[3] == 'o' && opt
[4] == '-')
611 size_t len
= strlen (opt
) - 3;
613 dup
= xmalloc (len
+ 1);
616 memcpy (dup
+ 2, opt
+ 5, len
- 2 + 1);
621 result
= cpp_handle_option (parse_in
, argc
, argv
);
624 lang_flag
= lang_flags
[(c_language
<< 1) + flag_objc
];
625 opt_index
= find_opt (opt
+ 1, lang_flag
);
626 if (opt_index
== N_OPTS
)
630 option
= &cl_options
[opt_index
];
632 /* Sort out any argument the switch takes. */
633 if (option
->flags
& CL_ARG
)
635 if (option
->flags
& CL_JOINED
)
637 /* Have arg point to the original switch. This is because
638 some code, such as disable_builtin_function, expects its
639 argument to be persistent until the program exits. */
640 arg
= argv
[0] + cl_options
[opt_index
].opt_len
+ 1;
642 arg
+= strlen ("no-");
645 /* If we don't have an argument, and CL_SEPARATE, try the next
646 argument in the vector. */
647 if (!arg
|| (*arg
== '\0' && option
->flags
& CL_SEPARATE
))
653 if (!arg
|| *arg
== '\0')
655 missing_arg (opt_index
);
661 /* Complain about the wrong language after we've swallowed any
662 necessary extra argument. Eventually make this a hard error
663 after the call to find_opt, and return argc. */
664 if (!(cl_options
[opt_index
].flags
& lang_flag
))
666 complain_wrong_lang (opt_index
);
670 switch (code
= option
->opt_code
)
672 case N_OPTS
: /* Shut GCC up. */
679 case OPT__output_pch
:
684 cpp_opts
->discard_comments
= 0;
688 cpp_opts
->discard_comments
= 0;
689 cpp_opts
->discard_comments_in_macro_exp
= 0;
693 flag_preprocess_only
= 1;
697 cpp_opts
->print_include_names
= 1;
701 if (strcmp (arg
, "-"))
702 add_path (xstrdup (arg
), BRACKET
, 0);
705 if (quote_chain_split
)
706 error ("-I- specified twice");
707 quote_chain_split
= true;
708 split_quote_chain ();
714 /* When doing dependencies with -M or -MM, suppress normal
715 preprocessed output, but still do -dM etc. as software
716 depends on this. Preprocessed output does occur if -MD, -MMD
717 or environment var dependency generation is used. */
718 cpp_opts
->deps
.style
= (code
== OPT_M
? DEPS_SYSTEM
: DEPS_USER
);
720 cpp_opts
->inhibit_warnings
= 1;
725 cpp_opts
->deps
.style
= (code
== OPT_MD
? DEPS_SYSTEM
: DEPS_USER
);
736 cpp_opts
->deps
.missing_files
= true;
741 cpp_opts
->deps
.phony_targets
= true;
747 defer_opt (code
, arg
);
751 flag_no_line_commands
= 1;
762 warn_char_subscripts
= on
;
763 warn_missing_braces
= on
;
764 warn_parentheses
= on
;
765 warn_return_type
= on
;
766 warn_sequence_point
= on
; /* Was C only. */
767 warn_sign_compare
= on
; /* Was C++ only. */
769 warn_strict_aliasing
= on
;
771 /* Only warn about unknown pragmas that are not in system
773 warn_unknown_pragmas
= on
;
775 /* We save the value of warn_uninitialized, since if they put
776 -Wuninitialized on the command line, we need to generate a
777 warning about not using it without also specifying -O. */
778 if (warn_uninitialized
!= 1)
779 warn_uninitialized
= (on
? 2 : 0);
781 if (c_language
== clk_c
)
782 /* We set this to 2 here, but 1 in -Wmain, so -ffreestanding
783 can turn it off only if it's not explicit. */
787 /* C++-specific warnings. */
788 warn_ctor_dtor_privacy
= on
;
791 warn_nontemplate_friend
= on
;
794 cpp_opts
->warn_trigraphs
= on
;
795 cpp_opts
->warn_comments
= on
;
796 cpp_opts
->warn_num_sign_change
= on
;
797 cpp_opts
->warn_multichar
= on
; /* Was C++ only. */
800 case OPT_Wbad_function_cast
:
801 warn_bad_function_cast
= on
;
808 case OPT_Wchar_subscripts
:
809 warn_char_subscripts
= on
;
814 cpp_opts
->warn_comments
= on
;
817 case OPT_Wconversion
:
818 warn_conversion
= on
;
821 case OPT_Wctor_dtor_privacy
:
822 warn_ctor_dtor_privacy
= on
;
825 case OPT_Wdeprecated
:
826 warn_deprecated
= on
;
827 cpp_opts
->warn_deprecated
= on
;
830 case OPT_Wdiv_by_zero
:
831 warn_div_by_zero
= on
;
838 case OPT_Wendif_labels
:
839 cpp_opts
->warn_endif_labels
= on
;
843 cpp_opts
->warnings_are_errors
= on
;
846 case OPT_Werror_implicit_function_decl
:
850 mesg_implicit_function_declaration
= 2;
853 case OPT_Wfloat_equal
:
854 warn_float_equal
= on
;
862 set_Wformat (atoi (arg
));
865 case OPT_Wformat_extra_args
:
866 warn_format_extra_args
= on
;
869 case OPT_Wformat_nonliteral
:
870 warn_format_nonliteral
= on
;
873 case OPT_Wformat_security
:
874 warn_format_security
= on
;
877 case OPT_Wformat_y2k
:
878 warn_format_y2k
= on
;
881 case OPT_Wformat_zero_length
:
882 warn_format_zero_length
= on
;
889 case OPT_Wimplicit_function_decl
:
890 mesg_implicit_function_declaration
= on
;
893 case OPT_Wimplicit_int
:
894 warn_implicit_int
= on
;
898 cpp_opts
->warn_import
= on
;
901 case OPT_Winvalid_pch
:
902 cpp_opts
->warn_invalid_pch
= on
;
916 case OPT_Wmissing_braces
:
917 warn_missing_braces
= on
;
920 case OPT_Wmissing_declarations
:
921 warn_missing_declarations
= on
;
924 case OPT_Wmissing_format_attribute
:
925 warn_missing_format_attribute
= on
;
928 case OPT_Wmissing_prototypes
:
929 warn_missing_prototypes
= on
;
933 cpp_opts
->warn_multichar
= on
;
936 case OPT_Wnested_externs
:
937 warn_nested_externs
= on
;
940 case OPT_Wnon_template_friend
:
941 warn_nontemplate_friend
= on
;
944 case OPT_Wnon_virtual_dtor
:
952 case OPT_Wold_style_cast
:
953 warn_old_style_cast
= on
;
956 case OPT_Woverloaded_virtual
:
957 warn_overloaded_virtual
= on
;
960 case OPT_Wparentheses
:
961 warn_parentheses
= on
;
964 case OPT_Wpmf_conversions
:
968 case OPT_Wpointer_arith
:
969 warn_pointer_arith
= on
;
980 case OPT_Wredundant_decls
:
981 warn_redundant_decls
= on
;
988 case OPT_Wreturn_type
:
989 warn_return_type
= on
;
992 case OPT_Wsequence_point
:
993 warn_sequence_point
= on
;
996 case OPT_Wsign_compare
:
997 warn_sign_compare
= on
;
1000 case OPT_Wsign_promo
:
1001 warn_sign_promo
= on
;
1004 case OPT_Wstrict_prototypes
:
1005 if (!on
&& c_language
== clk_cplusplus
)
1006 warning ("-Wno-strict-prototypes is not supported in C++");
1008 warn_strict_prototypes
= on
;
1015 case OPT_Wsystem_headers
:
1016 cpp_opts
->warn_system_headers
= on
;
1019 case OPT_Wtraditional
:
1020 warn_traditional
= on
;
1021 cpp_opts
->warn_traditional
= on
;
1024 case OPT_Wtrigraphs
:
1025 cpp_opts
->warn_trigraphs
= on
;
1028 case OPT_Wundeclared_selector
:
1029 warn_undeclared_selector
= on
;
1033 cpp_opts
->warn_undef
= on
;
1036 case OPT_Wunknown_pragmas
:
1037 /* Set to greater than 1, so that even unknown pragmas in
1038 system headers will be warned about. */
1039 warn_unknown_pragmas
= on
* 2;
1042 case OPT_Wunused_macros
:
1043 cpp_opts
->warn_unused_macros
= on
;
1046 case OPT_Wwrite_strings
:
1047 if (c_language
== clk_c
)
1048 flag_const_strings
= on
;
1050 warn_write_strings
= on
;
1054 if (c_language
== clk_c
)
1055 set_std_c89 (false, true);
1057 set_std_cxx98 (true);
1064 case OPT_fcond_mismatch
:
1065 if (c_language
== clk_c
)
1067 flag_cond_mismatch
= on
;
1072 case OPT_fall_virtual
:
1073 case OPT_fenum_int_equiv
:
1074 case OPT_fguiding_decls
:
1075 case OPT_fhonor_std
:
1076 case OPT_fhuge_objects
:
1077 case OPT_flabels_ok
:
1078 case OPT_fname_mangling
:
1080 case OPT_fnonnull_objects
:
1082 case OPT_fstrict_prototype
:
1083 case OPT_fthis_is_variable
:
1084 case OPT_fvtable_thunks
:
1086 warning ("switch \"%s\" is no longer supported", argv
[0]);
1089 case OPT_fabi_version
:
1090 flag_abi_version
= read_integral_parameter (arg
, argv
[0], 1);
1093 case OPT_faccess_control
:
1094 flag_access_control
= on
;
1097 case OPT_falt_external_templates
:
1098 flag_alt_external_templates
= on
;
1100 flag_external_templates
= true;
1102 warning ("switch \"%s\" is deprecated, please see documentation for details", argv
[0]);
1110 flag_no_builtin
= !on
;
1117 disable_builtin_function (arg
);
1120 case OPT_fdollars_in_identifiers
:
1121 dollars_in_ident
= on
;
1125 if (!on
|| !dump_switch_p (argv
[0] + strlen ("-f")))
1129 case OPT_ffreestanding
:
1131 /* Fall through... */
1134 flag_no_builtin
= !on
;
1135 /* warn_main will be 2 if set by -Wall, 1 if set by -Wmain */
1136 if (!on
&& warn_main
== 2)
1140 case OPT_fshort_double
:
1141 flag_short_double
= on
;
1144 case OPT_fshort_enums
:
1145 flag_short_enums
= on
;
1148 case OPT_fshort_wchar
:
1149 flag_short_wchar
= on
;
1152 case OPT_fsigned_bitfields
:
1153 flag_signed_bitfields
= on
;
1154 explicit_flag_signed_bitfields
= 1;
1157 case OPT_fsigned_char
:
1158 flag_signed_char
= on
;
1161 case OPT_funsigned_bitfields
:
1162 flag_signed_bitfields
= !on
;
1163 explicit_flag_signed_bitfields
= 1;
1166 case OPT_funsigned_char
:
1167 flag_signed_char
= !on
;
1170 case OPT_fcheck_new
:
1171 flag_check_new
= on
;
1174 case OPT_fconserve_space
:
1175 flag_conserve_space
= on
;
1178 case OPT_fconst_strings
:
1179 flag_const_strings
= on
;
1182 case OPT_fconstant_string_class
:
1183 constant_string_class_name
= arg
;
1186 case OPT_fdefault_inline
:
1187 flag_default_inline
= on
;
1190 case OPT_felide_constructors
:
1191 flag_elide_constructors
= on
;
1194 case OPT_fenforce_eh_specs
:
1195 flag_enforce_eh_specs
= on
;
1198 case OPT_fexternal_templates
:
1199 flag_external_templates
= on
;
1202 case OPT_ffixed_form
:
1203 case OPT_ffixed_line_length
:
1204 /* Fortran front end options ignored when preprocessing only. */
1205 if (flag_preprocess_only
)
1209 case OPT_ffor_scope
:
1210 flag_new_for_scope
= on
;
1213 case OPT_fgnu_keywords
:
1214 flag_no_gnu_keywords
= !on
;
1217 case OPT_fgnu_runtime
:
1218 flag_next_runtime
= !on
;
1221 case OPT_fhandle_exceptions
:
1222 warning ("-fhandle-exceptions has been renamed to -fexceptions (and is now on by default)");
1223 flag_exceptions
= on
;
1226 case OPT_fimplement_inlines
:
1227 flag_implement_inlines
= on
;
1230 case OPT_fimplicit_inline_templates
:
1231 flag_implicit_inline_templates
= on
;
1234 case OPT_fimplicit_templates
:
1235 flag_implicit_templates
= on
;
1238 case OPT_fms_extensions
:
1239 flag_ms_extensions
= on
;
1242 case OPT_fnext_runtime
:
1243 flag_next_runtime
= on
;
1246 case OPT_fnonansi_builtins
:
1247 flag_no_nonansi_builtin
= !on
;
1250 case OPT_foperator_names
:
1251 cpp_opts
->operator_names
= on
;
1254 case OPT_foptional_diags
:
1255 flag_optional_diags
= on
;
1259 cpp_opts
->restore_pch_deps
= on
;
1262 case OPT_fpermissive
:
1263 flag_permissive
= on
;
1266 case OPT_fpreprocessed
:
1267 cpp_opts
->preprocessed
= on
;
1271 flag_use_repository
= on
;
1273 flag_implicit_templates
= 0;
1280 case OPT_fshow_column
:
1281 cpp_opts
->show_column
= on
;
1285 flag_detailed_statistics
= on
;
1289 /* Don't recognize -fno-tabstop=. */
1293 /* It is documented that we silently ignore silly values. */
1296 long tabstop
= strtol (arg
, &endptr
, 10);
1297 if (*endptr
== '\0' && tabstop
>= 1 && tabstop
<= 100)
1298 cpp_opts
->tabstop
= tabstop
;
1302 case OPT_ftemplate_depth
:
1303 max_tinst_depth
= read_integral_parameter (arg
, argv
[0], 0);
1306 case OPT_fvtable_gc
:
1307 flag_vtable_gc
= on
;
1310 case OPT_fuse_cxa_atexit
:
1311 flag_use_cxa_atexit
= on
;
1319 flag_gen_declaration
= 1;
1323 add_path (xstrdup (arg
), AFTER
, 0);
1335 add_path (xstrdup (arg
), SYSTEM
, 0);
1338 case OPT_iwithprefix
:
1339 add_prefixed_path (arg
, SYSTEM
);
1342 case OPT_iwithprefixbefore
:
1343 add_prefixed_path (arg
, BRACKET
);
1347 cpp_set_lang (parse_in
, CLK_ASM
);
1358 case OPT_nostdincplusplus
:
1359 std_cxx_inc
= false;
1367 error ("output filename specified twice");
1372 /* We need to handle the -pedantic switches here, rather than in
1373 c_common_post_options, so that a subsequent -Wno-endif-labels
1374 is not overridden. */
1375 case OPT_pedantic_errors
:
1376 cpp_opts
->pedantic_errors
= 1;
1379 cpp_opts
->pedantic
= 1;
1380 cpp_opts
->warn_endif_labels
= 1;
1383 case OPT_print_objc_runtime_info
:
1384 print_struct_values
= 1;
1388 cpp_opts
->remap
= 1;
1391 case OPT_std_cplusplus98
:
1392 case OPT_std_gnuplusplus98
:
1393 set_std_cxx98 (code
== OPT_std_cplusplus98
/* ISO */);
1397 case OPT_std_iso9899_1990
:
1398 case OPT_std_iso9899_199409
:
1399 set_std_c89 (code
== OPT_std_iso9899_199409
/* c94 */, true /* ISO */);
1403 set_std_c89 (false /* c94 */, false /* ISO */);
1408 case OPT_std_iso9899_1999
:
1409 case OPT_std_iso9899_199x
:
1410 set_std_c99 (true /* ISO */);
1415 set_std_c99 (false /* ISO */);
1419 cpp_opts
->trigraphs
= 1;
1422 case OPT_traditional_cpp
:
1423 cpp_opts
->traditional
= 1;
1431 cpp_opts
->inhibit_warnings
= 1;
1445 /* Post-switch processing. */
1447 c_common_post_options (pfilename
)
1448 const char **pfilename
;
1450 /* Canonicalize the input and output filenames. */
1451 if (in_fname
== NULL
|| !strcmp (in_fname
, "-"))
1454 if (out_fname
== NULL
|| !strcmp (out_fname
, "-"))
1457 if (cpp_opts
->deps
.style
== DEPS_NONE
)
1458 check_deps_environment_vars ();
1460 handle_deferred_opts ();
1462 sanitize_cpp_opts ();
1464 register_include_chains (parse_in
, sysroot
, iprefix
,
1465 std_inc
, std_cxx_inc
&& c_language
== clk_cplusplus
,
1468 flag_inline_trees
= 1;
1470 /* Use tree inlining if possible. Function instrumentation is only
1471 done in the RTL level, so we disable tree inlining. */
1472 if (! flag_instrument_function_entry_exit
)
1474 if (!flag_no_inline
)
1476 if (flag_inline_functions
)
1478 flag_inline_trees
= 2;
1479 flag_inline_functions
= 0;
1483 /* Special format checking options don't work without -Wformat; warn if
1485 if (warn_format_y2k
&& !warn_format
)
1486 warning ("-Wformat-y2k ignored without -Wformat");
1487 if (warn_format_extra_args
&& !warn_format
)
1488 warning ("-Wformat-extra-args ignored without -Wformat");
1489 if (warn_format_zero_length
&& !warn_format
)
1490 warning ("-Wformat-zero-length ignored without -Wformat");
1491 if (warn_format_nonliteral
&& !warn_format
)
1492 warning ("-Wformat-nonliteral ignored without -Wformat");
1493 if (warn_format_security
&& !warn_format
)
1494 warning ("-Wformat-security ignored without -Wformat");
1495 if (warn_missing_format_attribute
&& !warn_format
)
1496 warning ("-Wmissing-format-attribute ignored without -Wformat");
1498 if (flag_preprocess_only
)
1500 /* Open the output now. We must do so even if flag_no_output is
1501 on, because there may be other output than from the actual
1502 preprocessing (e.g. from -dM). */
1503 if (out_fname
[0] == '\0')
1504 out_stream
= stdout
;
1506 out_stream
= fopen (out_fname
, "w");
1508 if (out_stream
== NULL
)
1510 fatal_io_error ("opening output file %s", out_fname
);
1514 init_pp_output (out_stream
);
1520 /* Yuk. WTF is this? I do know ObjC relies on it somewhere. */
1524 /* NOTE: we use in_fname here, not the one supplied. */
1525 *pfilename
= cpp_read_main_file (parse_in
, in_fname
, ident_hash
);
1527 saved_lineno
= lineno
;
1530 /* If an error has occurred in cpplib, note it so we fail
1532 errorcount
+= cpp_errors (parse_in
);
1534 return flag_preprocess_only
;
1537 /* Front end initialization common to C, ObjC and C++. */
1541 lineno
= saved_lineno
;
1543 /* Set up preprocessor arithmetic. Must be done after call to
1544 c_common_nodes_and_builtins for type nodes to be good. */
1545 cpp_opts
->precision
= TYPE_PRECISION (intmax_type_node
);
1546 cpp_opts
->char_precision
= TYPE_PRECISION (char_type_node
);
1547 cpp_opts
->int_precision
= TYPE_PRECISION (integer_type_node
);
1548 cpp_opts
->wchar_precision
= TYPE_PRECISION (wchar_type_node
);
1549 cpp_opts
->unsigned_wchar
= TREE_UNSIGNED (wchar_type_node
);
1551 if (flag_preprocess_only
)
1553 if (main_input_filename
)
1554 preprocess_file (parse_in
);
1558 /* Has to wait until now so that cpplib has its hash table. */
1564 /* Common finish hook for the C, ObjC and C++ front ends. */
1568 FILE *deps_stream
= NULL
;
1570 if (cpp_opts
->deps
.style
!= DEPS_NONE
)
1572 /* If -M or -MM was seen without -MF, default output to the
1575 deps_stream
= out_stream
;
1578 deps_stream
= fopen (deps_file
, deps_append
? "a": "w");
1580 fatal_io_error ("opening dependency file %s", deps_file
);
1584 /* For performance, avoid tearing down cpplib's internal structures
1585 with cpp_destroy (). */
1586 errorcount
+= cpp_finish (parse_in
, deps_stream
);
1588 if (deps_stream
&& deps_stream
!= out_stream
1589 && (ferror (deps_stream
) || fclose (deps_stream
)))
1590 fatal_io_error ("closing dependency file %s", deps_file
);
1592 if (out_stream
&& (ferror (out_stream
) || fclose (out_stream
)))
1593 fatal_io_error ("when writing output to %s", out_fname
);
1596 /* Either of two environment variables can specify output of
1597 dependencies. Their value is either "OUTPUT_FILE" or "OUTPUT_FILE
1598 DEPS_TARGET", where OUTPUT_FILE is the file to write deps info to
1599 and DEPS_TARGET is the target to mention in the deps. They also
1600 result in dependency information being appended to the output file
1601 rather than overwriting it, and like Sun's compiler
1602 SUNPRO_DEPENDENCIES suppresses the dependency on the main file. */
1604 check_deps_environment_vars ()
1608 GET_ENVIRONMENT (spec
, "DEPENDENCIES_OUTPUT");
1610 cpp_opts
->deps
.style
= DEPS_USER
;
1613 GET_ENVIRONMENT (spec
, "SUNPRO_DEPENDENCIES");
1616 cpp_opts
->deps
.style
= DEPS_SYSTEM
;
1617 cpp_opts
->deps
.ignore_main_file
= true;
1623 /* Find the space before the DEPS_TARGET, if there is one. */
1624 char *s
= strchr (spec
, ' ');
1627 /* Let the caller perform MAKE quoting. */
1628 defer_opt (OPT_MT
, s
+ 1);
1632 /* Command line -MF overrides environment variables and default. */
1640 /* Handle deferred command line switches. */
1642 handle_deferred_opts ()
1646 for (i
= 0; i
< deferred_count
; i
++)
1648 struct deferred_opt
*opt
= &deferred_opts
[i
];
1654 cpp_add_dependency_target (parse_in
, opt
->arg
, opt
->code
== OPT_MQ
);
1662 free (deferred_opts
);
1665 /* These settings are appropriate for GCC, but not necessarily so for
1666 cpplib as a library. */
1668 sanitize_cpp_opts ()
1670 /* If we don't know what style of dependencies to output, complain
1671 if any other dependency switches have been given. */
1672 if (deps_seen
&& cpp_opts
->deps
.style
== DEPS_NONE
)
1673 error ("to generate dependencies you must specify either -M or -MM");
1675 /* -dM and dependencies suppress normal output; do it here so that
1676 the last -d[MDN] switch overrides earlier ones. */
1677 if (flag_dump_macros
== 'M')
1680 /* Disable -dD, -dN and -dI if normal output is suppressed. Allow
1681 -dM since at least glibc relies on -M -dM to work. */
1684 if (flag_dump_macros
!= 'M')
1685 flag_dump_macros
= 0;
1686 flag_dump_includes
= 0;
1689 cpp_opts
->unsigned_char
= !flag_signed_char
;
1690 cpp_opts
->stdc_0_in_system_headers
= STDC_0_IN_SYSTEM_HEADERS
;
1692 /* We want -Wno-long-long to override -pedantic -std=non-c99
1693 and/or -Wtraditional, whatever the ordering. */
1694 cpp_opts
->warn_long_long
1695 = warn_long_long
&& ((!flag_isoc99
&& pedantic
) || warn_traditional
);
1698 /* Add include path with a prefix at the front of its name. */
1700 add_prefixed_path (suffix
, chain
)
1706 size_t prefix_len
, suffix_len
;
1708 suffix_len
= strlen (suffix
);
1709 prefix
= iprefix
? iprefix
: cpp_GCC_INCLUDE_DIR
;
1710 prefix_len
= iprefix
? strlen (iprefix
) : cpp_GCC_INCLUDE_DIR_len
;
1712 path
= xmalloc (prefix_len
+ suffix_len
+ 1);
1713 memcpy (path
, prefix
, prefix_len
);
1714 memcpy (path
+ prefix_len
, suffix
, suffix_len
);
1715 path
[prefix_len
+ suffix_len
] = '\0';
1717 add_path (path
, chain
, 0);
1720 /* Set the C 89 standard (with 1994 amendments if C94, without GNU
1721 extensions if ISO). There is no concept of gnu94. */
1723 set_std_c89 (c94
, iso
)
1726 cpp_set_lang (parse_in
, c94
? CLK_STDC94
: iso
? CLK_STDC89
: CLK_GNUC89
);
1729 flag_no_gnu_keywords
= iso
;
1730 flag_no_nonansi_builtin
= iso
;
1731 flag_noniso_default_format_attributes
= !iso
;
1734 flag_writable_strings
= 0;
1737 /* Set the C 99 standard (without GNU extensions if ISO). */
1742 cpp_set_lang (parse_in
, iso
? CLK_STDC99
: CLK_GNUC99
);
1744 flag_no_nonansi_builtin
= iso
;
1745 flag_noniso_default_format_attributes
= !iso
;
1749 flag_writable_strings
= 0;
1752 /* Set the C++ 98 standard (without GNU extensions if ISO). */
1757 cpp_set_lang (parse_in
, iso
? CLK_CXX98
: CLK_GNUCXX
);
1758 flag_no_gnu_keywords
= iso
;
1759 flag_no_nonansi_builtin
= iso
;
1760 flag_noniso_default_format_attributes
= !iso
;
1764 /* Handle setting implicit to ON. */
1770 warn_implicit_int
= on
;
1773 if (mesg_implicit_function_declaration
!= 2)
1774 mesg_implicit_function_declaration
= 1;
1777 mesg_implicit_function_declaration
= 0;
1780 /* Args to -d specify what to dump. Silently ignore
1781 unrecognized options; they may be aimed at toplev.c. */
1788 while ((c
= *arg
++) != '\0')
1791 case 'M': /* Dump macros only. */
1792 case 'N': /* Dump names. */
1793 case 'D': /* Dump definitions. */
1794 flag_dump_macros
= c
;
1798 flag_dump_includes
= 1;
1803 /* Write a slash-separated list of languages in FLAGS to BUF. */
1805 write_langs (buf
, flags
)
1810 if (flags
& CL_C_ONLY
)
1812 if (flags
& CL_OBJC_ONLY
)
1816 strcat (buf
, "ObjC");
1818 if (flags
& CL_CXX_ONLY
)
1822 strcat (buf
, "C++");
1826 /* Complain that switch OPT_INDEX does not apply to this front end. */
1828 complain_wrong_lang (opt_index
)
1831 char ok_langs
[60], bad_langs
[60];
1832 int ok_flags
= cl_options
[opt_index
].flags
;
1834 write_langs (ok_langs
, ok_flags
);
1835 write_langs (bad_langs
, ~ok_flags
);
1836 warning ("\"-%s\" is valid for %s but not for %s",
1837 cl_options
[opt_index
].opt_text
, ok_langs
, bad_langs
);
1840 /* Handle --help output. */
1844 /* To keep the lines from getting too long for some compilers, limit
1845 to about 500 characters (6 lines) per chunk. */
1848 -include <file> Include the contents of <file> before other files\n\
1849 -imacros <file> Accept definition of macros in <file>\n\
1850 -iprefix <path> Specify <path> as a prefix for next two options\n\
1851 -iwithprefix <dir> Add <dir> to the end of the system include path\n\
1852 -iwithprefixbefore <dir> Add <dir> to the end of the main include path\n\
1853 -isystem <dir> Add <dir> to the start of the system include path\n\
1856 -idirafter <dir> Add <dir> to the end of the system include path\n\
1857 -I <dir> Add <dir> to the end of the main include path\n\
1858 -I- Fine-grained include path control; see info docs\n\
1859 -nostdinc Do not search system include directories\n\
1860 (dirs specified with -isystem will still be used)\n\
1861 -nostdinc++ Do not search system include directories for C++\n\
1862 -o <file> Put output into <file>\n\
1865 -trigraphs Support ISO C trigraphs\n\
1866 -std=<std name> Specify the conformance standard; one of:\n\
1867 gnu89, gnu99, c89, c99, iso9899:1990,\n\
1868 iso9899:199409, iso9899:1999, c++98\n\
1869 -w Inhibit warning messages\n\
1870 -W[no-]trigraphs Warn if trigraphs are encountered\n\
1871 -W[no-]comment{s} Warn if one comment starts inside another\n\
1874 -W[no-]traditional Warn about features not present in traditional C\n\
1875 -W[no-]undef Warn if an undefined macro is used by #if\n\
1876 -W[no-]import Warn about the use of the #import directive\n\
1879 -W[no-]error Treat all warnings as errors\n\
1880 -W[no-]system-headers Do not suppress warnings from system headers\n\
1881 -W[no-]all Enable most preprocessor warnings\n\
1884 -M Generate make dependencies\n\
1885 -MM As -M, but ignore system header files\n\
1886 -MD Generate make dependencies and compile\n\
1887 -MMD As -MD, but ignore system header files\n\
1888 -MF <file> Write dependency output to the given file\n\
1889 -MG Treat missing header file as generated files\n\
1892 -MP Generate phony targets for all headers\n\
1893 -MQ <target> Add a MAKE-quoted target\n\
1894 -MT <target> Add an unquoted target\n\
1897 -D<macro> Define a <macro> with string '1' as its value\n\
1898 -D<macro>=<val> Define a <macro> with <val> as its value\n\
1899 -A<question>=<answer> Assert the <answer> to <question>\n\
1900 -A-<question>=<answer> Disable the <answer> to <question>\n\
1901 -U<macro> Undefine <macro> \n\
1902 -v Display the version number\n\
1905 -H Print the name of header files as they are used\n\
1906 -C Do not discard comments\n\
1907 -dM Display a list of macro definitions active at end\n\
1908 -dD Preserve macro definitions in output\n\
1909 -dN As -dD except that only the names are preserved\n\
1910 -dI Include #include directives in the output\n\
1913 -f[no-]preprocessed Treat the input file as already preprocessed\n\
1914 -ftabstop=<number> Distance between tab stops for column reporting\n\
1915 -isysroot <dir> Set <dir> to be the system root directory\n\
1916 -P Do not generate #line directives\n\
1917 -remap Remap file names when including files\n\
1918 --help Display this information\n\