OSDN Git Service

* c-common.h (enum rid): Remove RID_BOUNDED, RID_UNBOUNDED.
[pf3gnuchains/gcc-fork.git] / gcc / c-opts.c
1 /* C/ObjC/C++ command line option handling.
2    Copyright (C) 2002, 2003 Free Software Foundation, Inc.
3    Contributed by Neil Booth.
4
5 This file is part of GCC.
6
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
10 version.
11
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
15 for more details.
16
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
20 02111-1307, USA.  */
21
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "tree.h"
27 #include "c-common.h"
28 #include "c-pragma.h"
29 #include "flags.h"
30 #include "toplev.h"
31 #include "langhooks.h"
32 #include "tree-inline.h"
33 #include "diagnostic.h"
34 #include "intl.h"
35 #include "cppdefault.h"
36 #include "c-incpath.h"
37 #include "debug.h"              /* For debug_hooks.  */
38
39 #ifndef DOLLARS_IN_IDENTIFIERS
40 # define DOLLARS_IN_IDENTIFIERS true
41 #endif
42
43 #ifndef TARGET_SYSTEM_ROOT
44 # define TARGET_SYSTEM_ROOT NULL
45 #endif
46
47 #ifndef TARGET_EBCDIC
48 # define TARGET_EBCDIC 0
49 #endif
50
51 static int saved_lineno;
52
53 /* CPP's options.  */
54 static cpp_options *cpp_opts;
55
56 /* Input filename.  */
57 static const char *in_fname;
58
59 /* Filename and stream for preprocessed output.  */
60 static const char *out_fname;
61 static FILE *out_stream;
62
63 /* Append dependencies to deps_file.  */
64 static bool deps_append;
65
66 /* If dependency switches (-MF etc.) have been given.  */
67 static bool deps_seen;
68
69 /* If -v seen.  */
70 static bool verbose;
71
72 /* Dependency output file.  */
73 static const char *deps_file;
74
75 /* The prefix given by -iprefix, if any.  */
76 static const char *iprefix;
77
78 /* The system root, if any.  Overridden by -isysroot.  */
79 static const char *sysroot = TARGET_SYSTEM_ROOT;
80
81 /* Zero disables all standard directories for headers.  */
82 static bool std_inc = true;
83
84 /* Zero disables the C++-specific standard directories for headers.  */
85 static bool std_cxx_inc = true;
86
87 /* If the quote chain has been split by -I-.  */
88 static bool quote_chain_split;
89
90 /* If -Wunused-macros.  */
91 static bool warn_unused_macros;
92
93 /* Number of deferred options, deferred options array size.  */
94 static size_t deferred_count, deferred_size;
95
96 /* Number of deferred options scanned for -include.  */
97 static size_t include_cursor;
98
99 static void missing_arg PARAMS ((size_t));
100 static size_t find_opt PARAMS ((const char *, int));
101 static void set_Wimplicit PARAMS ((int));
102 static void complain_wrong_lang PARAMS ((size_t));
103 static void write_langs PARAMS ((char *, int));
104 static void print_help PARAMS ((void));
105 static void handle_OPT_d PARAMS ((const char *));
106 static void set_std_cxx98 PARAMS ((int));
107 static void set_std_c89 PARAMS ((int, int));
108 static void set_std_c99 PARAMS ((int));
109 static void check_deps_environment_vars PARAMS ((void));
110 static void handle_deferred_opts PARAMS ((void));
111 static void sanitize_cpp_opts PARAMS ((void));
112 static void add_prefixed_path PARAMS ((const char *, size_t));
113 static void push_command_line_include PARAMS ((void));
114 static void cb_file_change PARAMS ((cpp_reader *, const struct line_map *));
115 static void finish_options PARAMS ((void));
116
117 #ifndef STDC_0_IN_SYSTEM_HEADERS
118 #define STDC_0_IN_SYSTEM_HEADERS 0
119 #endif
120
121 #define CL_C_ONLY       (1 << 0) /* Only C.  */
122 #define CL_OBJC_ONLY    (1 << 1) /* Only ObjC.  */
123 #define CL_CXX_ONLY     (1 << 2) /* Only C++.  */
124 #define CL_OBJCXX_ONLY  (1 << 3) /* Only ObjC++.  */
125 #define CL_JOINED       (1 << 4) /* If takes joined argument.  */
126 #define CL_SEPARATE     (1 << 5) /* If takes a separate argument.  */
127
128 #define CL_ARG          (CL_JOINED | CL_SEPARATE)
129 #define CL_C            (CL_C_ONLY | CL_OBJC_ONLY)
130 #define CL_OBJC         (CL_OBJC_ONLY | CL_OBJCXX_ONLY)
131 #define CL_CXX          (CL_CXX_ONLY | CL_OBJCXX_ONLY)
132 #define CL_ALL          (CL_C | CL_CXX)
133
134 /* This is the list of all command line options, with the leading "-"
135    removed.  It must be sorted in ASCII collating order.  All options
136    beginning with "f" or "W" are implicitly assumed to take a "no-"
137    form; this form should not be listed.  The variable "on" is true if
138    the positive form is given, otherwise it is false.  If you don't
139    want to allow a "no-" form, your handler should reject "on" being
140    false by returning zero.  See, for example, the handling of
141    -ftabstop=.
142
143    If the user gives an option to a front end that doesn't support it,
144    an error is output, mentioning which front ends the option is valid
145    for.  If you don't want this, you must accept it for all front
146    ends, and test for the front end in the option handler.  See, for
147    example, the handling of -Wno-strict-prototypes for C++.
148
149    If you request an argument with CL_JOINED, CL_SEPARATE or their
150    combination CL_ARG, it is stored in the variable "arg", which is
151    guaranteed to be non-NULL and to not be an empty string.  It points
152    to the argument either within the argv[] vector or within one of
153    that vector's strings, and so the text is permanent and copies need
154    not be made.  Be sure to add an error message in missing_arg() if
155    the default is not appropriate.  */
156
157 #define COMMAND_LINE_OPTIONS                                                 \
158   OPT("-help",                  CL_ALL,   OPT__help)                         \
159   OPT("-output-pch=",           CL_ALL | CL_ARG, OPT__output_pch)            \
160   OPT("A",                      CL_ALL | CL_ARG, OPT_A)                      \
161   OPT("C",                      CL_ALL,   OPT_C)                             \
162   OPT("CC",                     CL_ALL,   OPT_CC)                            \
163   OPT("D",                      CL_ALL | CL_ARG, OPT_D)                      \
164   OPT("E",                      CL_ALL,   OPT_E)                             \
165   OPT("H",                      CL_ALL,   OPT_H)                             \
166   OPT("I",                      CL_ALL | CL_ARG, OPT_I)                      \
167   OPT("M",                      CL_ALL,   OPT_M)                             \
168   OPT("MD",                     CL_ALL | CL_SEPARATE, OPT_MD)                \
169   OPT("MF",                     CL_ALL | CL_ARG, OPT_MF)                     \
170   OPT("MG",                     CL_ALL,   OPT_MG)                            \
171   OPT("MM",                     CL_ALL,   OPT_MM)                            \
172   OPT("MMD",                    CL_ALL | CL_SEPARATE, OPT_MMD)               \
173   OPT("MP",                     CL_ALL,   OPT_MP)                            \
174   OPT("MQ",                     CL_ALL | CL_ARG, OPT_MQ)                     \
175   OPT("MT",                     CL_ALL | CL_ARG, OPT_MT)                     \
176   OPT("P",                      CL_ALL,   OPT_P)                             \
177   OPT("U",                      CL_ALL | CL_ARG, OPT_U)                      \
178   OPT("Wabi",                   CL_CXX,   OPT_Wabi)                          \
179   OPT("Wall",                   CL_ALL,   OPT_Wall)                          \
180   OPT("Wbad-function-cast",     CL_C,     OPT_Wbad_function_cast)            \
181   OPT("Wcast-qual",             CL_ALL,   OPT_Wcast_qual)                    \
182   OPT("Wchar-subscripts",       CL_ALL,   OPT_Wchar_subscripts)              \
183   OPT("Wcomment",               CL_ALL,   OPT_Wcomment)                      \
184   OPT("Wcomments",              CL_ALL,   OPT_Wcomments)                     \
185   OPT("Wconversion",            CL_ALL,   OPT_Wconversion)                   \
186   OPT("Wctor-dtor-privacy",     CL_CXX,   OPT_Wctor_dtor_privacy)            \
187   OPT("Wdeprecated",            CL_CXX,   OPT_Wdeprecated)                   \
188   OPT("Wdiv-by-zero",           CL_C,     OPT_Wdiv_by_zero)                  \
189   OPT("Weffc++",                CL_CXX,   OPT_Weffcxx)                       \
190   OPT("Wendif-labels",          CL_ALL,   OPT_Wendif_labels)                 \
191   OPT("Werror",                 CL_ALL,   OPT_Werror)                        \
192   OPT("Werror-implicit-function-declaration",                                \
193                                 CL_C,     OPT_Werror_implicit_function_decl) \
194   OPT("Wfloat-equal",           CL_ALL,   OPT_Wfloat_equal)                  \
195   OPT("Wformat",                CL_ALL,   OPT_Wformat)                       \
196   OPT("Wformat-extra-args",     CL_ALL,   OPT_Wformat_extra_args)            \
197   OPT("Wformat-nonliteral",     CL_ALL,   OPT_Wformat_nonliteral)            \
198   OPT("Wformat-security",       CL_ALL,   OPT_Wformat_security)              \
199   OPT("Wformat-y2k",            CL_ALL,   OPT_Wformat_y2k)                   \
200   OPT("Wformat-zero-length",    CL_C,     OPT_Wformat_zero_length)           \
201   OPT("Wformat=",               CL_ALL | CL_JOINED, OPT_Wformat_eq)          \
202   OPT("Wimplicit",              CL_ALL,   OPT_Wimplicit)                     \
203   OPT("Wimplicit-function-declaration", CL_C, OPT_Wimplicit_function_decl)   \
204   OPT("Wimplicit-int",          CL_C,     OPT_Wimplicit_int)                 \
205   OPT("Wimport",                CL_ALL,   OPT_Wimport)                       \
206   OPT("Winvalid-offsetof",      CL_CXX,   OPT_Winvalid_offsetof)             \
207   OPT("Winvalid-pch",           CL_ALL,   OPT_Winvalid_pch)                  \
208   OPT("Wlong-long",             CL_ALL,   OPT_Wlong_long)                    \
209   OPT("Wmain",                  CL_C,     OPT_Wmain)                         \
210   OPT("Wmissing-braces",        CL_ALL,   OPT_Wmissing_braces)               \
211   OPT("Wmissing-declarations",  CL_C,     OPT_Wmissing_declarations)         \
212   OPT("Wmissing-format-attribute",CL_ALL, OPT_Wmissing_format_attribute)     \
213   OPT("Wmissing-prototypes",    CL_C,     OPT_Wmissing_prototypes)           \
214   OPT("Wmultichar",             CL_ALL,   OPT_Wmultichar)                    \
215   OPT("Wnested-externs",        CL_C,     OPT_Wnested_externs)               \
216   OPT("Wnon-template-friend",   CL_CXX,   OPT_Wnon_template_friend)          \
217   OPT("Wnon-virtual-dtor",      CL_CXX,   OPT_Wnon_virtual_dtor)             \
218   OPT("Wnonnull",               CL_C,     OPT_Wnonnull)                      \
219   OPT("Wold-style-cast",        CL_CXX,   OPT_Wold_style_cast)               \
220   OPT("Woverloaded-virtual",    CL_CXX,   OPT_Woverloaded_virtual)           \
221   OPT("Wparentheses",           CL_ALL,   OPT_Wparentheses)                  \
222   OPT("Wpmf-conversions",       CL_CXX,   OPT_Wpmf_conversions)              \
223   OPT("Wpointer-arith",         CL_ALL,   OPT_Wpointer_arith)                \
224   OPT("Wprotocol",              CL_OBJC,  OPT_Wprotocol)                     \
225   OPT("Wredundant-decls",       CL_ALL,   OPT_Wredundant_decls)              \
226   OPT("Wreorder",               CL_CXX,   OPT_Wreorder)                      \
227   OPT("Wreturn-type",           CL_ALL,   OPT_Wreturn_type)                  \
228   OPT("Wselector",              CL_OBJC,  OPT_Wselector)                     \
229   OPT("Wsequence-point",        CL_C,     OPT_Wsequence_point)               \
230   OPT("Wsign-compare",          CL_ALL,   OPT_Wsign_compare)                 \
231   OPT("Wsign-promo",            CL_CXX,   OPT_Wsign_promo)                   \
232   OPT("Wstrict-prototypes",     CL_C,     OPT_Wstrict_prototypes)            \
233   OPT("Wsynth",                 CL_CXX,   OPT_Wsynth)                        \
234   OPT("Wsystem-headers",        CL_ALL,   OPT_Wsystem_headers)               \
235   OPT("Wtraditional",           CL_C,     OPT_Wtraditional)                  \
236   OPT("Wtrigraphs",             CL_ALL,   OPT_Wtrigraphs)                    \
237   OPT("Wundeclared-selector",   CL_OBJC,  OPT_Wundeclared_selector)          \
238   OPT("Wundef",                 CL_ALL,   OPT_Wundef)                        \
239   OPT("Wunknown-pragmas",       CL_ALL,   OPT_Wunknown_pragmas)              \
240   OPT("Wunused-macros",         CL_ALL,   OPT_Wunused_macros)                \
241   OPT("Wwrite-strings",         CL_ALL,   OPT_Wwrite_strings)                \
242   OPT("ansi",                   CL_ALL,   OPT_ansi)                          \
243   OPT("d",                      CL_ALL | CL_JOINED, OPT_d)                   \
244   OPT("fabi-version=",          CL_CXX | CL_JOINED, OPT_fabi_version)        \
245   OPT("faccess-control",        CL_CXX,   OPT_faccess_control)               \
246   OPT("fall-virtual",           CL_CXX,   OPT_fall_virtual)                  \
247   OPT("falt-external-templates",CL_CXX,   OPT_falt_external_templates)       \
248   OPT("fasm",                   CL_ALL,   OPT_fasm)                          \
249   OPT("fbuiltin",               CL_ALL,   OPT_fbuiltin)                      \
250   OPT("fbuiltin-",              CL_ALL | CL_JOINED, OPT_fbuiltin_)           \
251   OPT("fcheck-new",             CL_CXX,   OPT_fcheck_new)                    \
252   OPT("fcond-mismatch",         CL_ALL,   OPT_fcond_mismatch)                \
253   OPT("fconserve-space",        CL_CXX,   OPT_fconserve_space)               \
254   OPT("fconst-strings",         CL_CXX,   OPT_fconst_strings)                \
255   OPT("fconstant-string-class=", CL_OBJC | CL_JOINED,                        \
256                                           OPT_fconstant_string_class)        \
257   OPT("fdefault-inline",        CL_CXX,   OPT_fdefault_inline)               \
258   OPT("fdollars-in-identifiers",CL_ALL,   OPT_fdollars_in_identifiers)       \
259   OPT("fdump-",                 CL_ALL | CL_JOINED, OPT_fdump)               \
260   OPT("felide-constructors",    CL_CXX,   OPT_felide_constructors)           \
261   OPT("fenforce-eh-specs",      CL_CXX,   OPT_fenforce_eh_specs)             \
262   OPT("fenum-int-equiv",        CL_CXX,   OPT_fenum_int_equiv)               \
263   OPT("fexternal-templates",    CL_CXX,   OPT_fexternal_templates)           \
264   OPT("ffixed-form",            CL_C,     OPT_ffixed_form)                   \
265   OPT("ffixed-line-length-",    CL_C | CL_JOINED, OPT_ffixed_line_length)    \
266   OPT("ffor-scope",             CL_CXX,   OPT_ffor_scope)                    \
267   OPT("ffreestanding",          CL_C,     OPT_ffreestanding)                 \
268   OPT("fgnu-keywords",          CL_CXX,   OPT_fgnu_keywords)                 \
269   OPT("fgnu-runtime",           CL_OBJC,  OPT_fgnu_runtime)                  \
270   OPT("fguiding-decls",         CL_CXX,   OPT_fguiding_decls)                \
271   OPT("fhandle-exceptions",     CL_CXX,   OPT_fhandle_exceptions)            \
272   OPT("fhonor-std",             CL_CXX,   OPT_fhonor_std)                    \
273   OPT("fhosted",                CL_C,     OPT_fhosted)                       \
274   OPT("fhuge-objects",          CL_CXX,   OPT_fhuge_objects)                 \
275   OPT("fimplement-inlines",     CL_CXX,   OPT_fimplement_inlines)            \
276   OPT("fimplicit-inline-templates", CL_CXX, OPT_fimplicit_inline_templates)  \
277   OPT("fimplicit-templates",    CL_CXX,   OPT_fimplicit_templates)           \
278   OPT("flabels-ok",             CL_CXX,   OPT_flabels_ok)                    \
279   OPT("fms-extensions",         CL_ALL,   OPT_fms_extensions)                \
280   OPT("fname-mangling-version-",CL_CXX | CL_JOINED, OPT_fname_mangling)      \
281   OPT("fnew-abi",               CL_CXX,   OPT_fnew_abi)                      \
282   OPT("fnext-runtime",          CL_OBJC,  OPT_fnext_runtime)                 \
283   OPT("fnonansi-builtins",      CL_CXX,   OPT_fnonansi_builtins)             \
284   OPT("fnonnull-objects",       CL_CXX,   OPT_fnonnull_objects)              \
285   OPT("foperator-names",        CL_CXX,   OPT_foperator_names)               \
286   OPT("foptional-diags",        CL_CXX,   OPT_foptional_diags)               \
287   OPT("fpch-deps",              CL_ALL,   OPT_fpch_deps)                     \
288   OPT("fpermissive",            CL_CXX,   OPT_fpermissive)                   \
289   OPT("fpreprocessed",          CL_ALL,   OPT_fpreprocessed)                 \
290   OPT("frepo",                  CL_CXX,   OPT_frepo)                         \
291   OPT("frtti",                  CL_CXX,   OPT_frtti)                         \
292   OPT("fshort-double",          CL_ALL,   OPT_fshort_double)                 \
293   OPT("fshort-enums",           CL_ALL,   OPT_fshort_enums)                  \
294   OPT("fshort-wchar",           CL_ALL,   OPT_fshort_wchar)                  \
295   OPT("fshow-column",           CL_ALL,   OPT_fshow_column)                  \
296   OPT("fsigned-bitfields",      CL_ALL,   OPT_fsigned_bitfields)             \
297   OPT("fsigned-char",           CL_ALL,   OPT_fsigned_char)                  \
298   OPT("fsquangle",              CL_CXX,   OPT_fsquangle)                     \
299   OPT("fstats",                 CL_CXX,   OPT_fstats)                        \
300   OPT("fstrict-prototype",      CL_CXX,   OPT_fstrict_prototype)             \
301   OPT("ftabstop=",              CL_ALL | CL_JOINED, OPT_ftabstop)            \
302   OPT("ftemplate-depth-",       CL_CXX | CL_JOINED, OPT_ftemplate_depth)     \
303   OPT("fthis-is-variable",      CL_CXX,   OPT_fthis_is_variable)             \
304   OPT("funsigned-bitfields",    CL_ALL,   OPT_funsigned_bitfields)           \
305   OPT("funsigned-char",         CL_ALL,   OPT_funsigned_char)                \
306   OPT("fuse-cxa-atexit",        CL_CXX,   OPT_fuse_cxa_atexit)               \
307   OPT("fvtable-gc",             CL_CXX,   OPT_fvtable_gc)                    \
308   OPT("fvtable-thunks",         CL_CXX,   OPT_fvtable_thunks)                \
309   OPT("fweak",                  CL_CXX,   OPT_fweak)                         \
310   OPT("fxref",                  CL_CXX,   OPT_fxref)                         \
311   OPT("gen-decls",              CL_OBJC,  OPT_gen_decls)                     \
312   OPT("idirafter",              CL_ALL | CL_ARG, OPT_idirafter)              \
313   OPT("imacros",                CL_ALL | CL_ARG, OPT_imacros)                \
314   OPT("include",                CL_ALL | CL_ARG, OPT_include)                \
315   OPT("iprefix",                CL_ALL | CL_ARG, OPT_iprefix)                \
316   OPT("isysroot",               CL_ALL | CL_ARG, OPT_isysroot)               \
317   OPT("isystem",                CL_ALL | CL_ARG, OPT_isystem)                \
318   OPT("iwithprefix",            CL_ALL | CL_ARG, OPT_iwithprefix)            \
319   OPT("iwithprefixbefore",      CL_ALL | CL_ARG, OPT_iwithprefixbefore)      \
320   OPT("lang-asm",               CL_C_ONLY, OPT_lang_asm)                     \
321   OPT("lang-objc",              CL_ALL,   OPT_lang_objc)                     \
322   OPT("nostdinc",               CL_ALL,   OPT_nostdinc)                      \
323   OPT("nostdinc++",             CL_ALL,   OPT_nostdincplusplus)              \
324   OPT("o",                      CL_ALL | CL_ARG, OPT_o)                      \
325   OPT("pedantic",               CL_ALL,   OPT_pedantic)                      \
326   OPT("pedantic-errors",        CL_ALL,   OPT_pedantic_errors)               \
327   OPT("print-objc-runtime-info", CL_OBJC, OPT_print_objc_runtime_info)       \
328   OPT("remap",                  CL_ALL,   OPT_remap)                         \
329   OPT("std=c++98",              CL_CXX,   OPT_std_cplusplus98)               \
330   OPT("std=c89",                CL_C,     OPT_std_c89)                       \
331   OPT("std=c99",                CL_C,     OPT_std_c99)                       \
332   OPT("std=c9x",                CL_C,     OPT_std_c9x)                       \
333   OPT("std=gnu++98",            CL_CXX,   OPT_std_gnuplusplus98)             \
334   OPT("std=gnu89",              CL_C,     OPT_std_gnu89)                     \
335   OPT("std=gnu99",              CL_C,     OPT_std_gnu99)                     \
336   OPT("std=gnu9x",              CL_C,     OPT_std_gnu9x)                     \
337   OPT("std=iso9899:1990",       CL_C,     OPT_std_iso9899_1990)              \
338   OPT("std=iso9899:199409",     CL_C,     OPT_std_iso9899_199409)            \
339   OPT("std=iso9899:1999",       CL_C,     OPT_std_iso9899_1999)              \
340   OPT("std=iso9899:199x",       CL_C,     OPT_std_iso9899_199x)              \
341   OPT("traditional-cpp",        CL_ALL,   OPT_traditional_cpp)               \
342   OPT("trigraphs",              CL_ALL,   OPT_trigraphs)                     \
343   OPT("undef",                  CL_ALL,   OPT_undef)                         \
344   OPT("v",                      CL_ALL,   OPT_v)                             \
345   OPT("w",                      CL_ALL,   OPT_w)
346
347 #define OPT(text, flags, code) code,
348 enum opt_code
349 {
350   COMMAND_LINE_OPTIONS
351   N_OPTS
352 };
353 #undef OPT
354
355 struct cl_option
356 {
357   const char *opt_text;
358   unsigned char opt_len;
359   unsigned char flags;
360   ENUM_BITFIELD (opt_code) opt_code : 2 * CHAR_BIT;
361 };
362
363 #define OPT(text, flags, code) { text, sizeof(text) - 1, flags, code },
364 #ifdef HOST_EBCDIC
365 static struct cl_option cl_options[] =
366 #else
367 static const struct cl_option cl_options[] =
368 #endif
369 {
370   COMMAND_LINE_OPTIONS
371 };
372 #undef OPT
373 #undef COMMAND_LINE_OPTIONS
374
375 /* Holds switches parsed by c_common_decode_option (), but whose
376    handling is deferred to c_common_post_options ().  */
377 static void defer_opt PARAMS ((enum opt_code, const char *));
378 static struct deferred_opt
379 {
380   enum opt_code code;
381   const char *arg;
382 } *deferred_opts;
383
384
385 #ifdef HOST_EBCDIC
386 static int opt_comp PARAMS ((const void *, const void *));
387
388 /* Run-time sorting of options array.  */
389 static int
390 opt_comp (p1, p2)
391      const void *p1, *p2;
392 {
393   return strcmp (((struct cl_option *) p1)->opt_text,
394                  ((struct cl_option *) p2)->opt_text);
395 }
396 #endif
397
398 /* Complain that switch OPT_INDEX expects an argument but none was
399    provided.  */
400 static void
401 missing_arg (opt_index)
402      size_t opt_index;
403 {
404   const char *opt_text = cl_options[opt_index].opt_text;
405
406   switch (cl_options[opt_index].opt_code)
407     {
408     case OPT__output_pch:
409     case OPT_Wformat_eq:
410     case OPT_d:
411     case OPT_fabi_version:
412     case OPT_fbuiltin_:
413     case OPT_fdump:
414     case OPT_fname_mangling:
415     case OPT_ftabstop:
416     case OPT_ftemplate_depth:
417     case OPT_iprefix:
418     case OPT_iwithprefix:
419     case OPT_iwithprefixbefore:
420     default:
421       error ("missing argument to \"-%s\"", opt_text);
422       break;
423
424     case OPT_fconstant_string_class:
425       error ("no class name specified with \"-%s\"", opt_text);
426       break;
427
428     case OPT_A:
429       error ("assertion missing after \"-%s\"", opt_text);
430       break;
431
432     case OPT_D:
433     case OPT_U:
434       error ("macro name missing after \"-%s\"", opt_text);
435       break;
436
437     case OPT_I:
438     case OPT_idirafter:
439     case OPT_isysroot:
440     case OPT_isystem:
441       error ("missing path after \"-%s\"", opt_text);
442       break;
443
444     case OPT_MF:
445     case OPT_MD:
446     case OPT_MMD:
447     case OPT_include:
448     case OPT_imacros:
449     case OPT_o:
450       error ("missing filename after \"-%s\"", opt_text);
451       break;
452
453     case OPT_MQ:
454     case OPT_MT:
455       error ("missing target after \"-%s\"", opt_text);
456       break;
457     }
458 }
459
460 /* Perform a binary search to find which option the command-line INPUT
461    matches.  Returns its index in the option array, and N_OPTS on
462    failure.
463
464    Complications arise since some options can be suffixed with an
465    argument, and multiple complete matches can occur, e.g. -pedantic
466    and -pedantic-errors.  Also, some options are only accepted by some
467    languages.  If a switch matches for a different language and
468    doesn't match any alternatives for the true front end, the index of
469    the matched switch is returned anyway.  The caller should check for
470    this case.  */
471 static size_t
472 find_opt (input, lang_flag)
473      const char *input;
474      int lang_flag;
475 {
476   size_t md, mn, mx;
477   size_t opt_len;
478   size_t result = N_OPTS;
479   int comp;
480
481   mn = 0;
482   mx = N_OPTS;
483
484   while (mx > mn)
485     {
486       md = (mn + mx) / 2;
487
488       opt_len = cl_options[md].opt_len;
489       comp = strncmp (input, cl_options[md].opt_text, opt_len);
490
491       if (comp < 0)
492         mx = md;
493       else if (comp > 0)
494         mn = md + 1;
495       else
496         {
497           /* The switch matches.  It it an exact match?  */
498           if (input[opt_len] == '\0')
499             return md;
500           else
501             {
502               mn = md + 1;
503
504               /* If the switch takes no arguments this is not a proper
505                  match, so we continue the search (e.g. input="stdc++"
506                  match was "stdc").  */
507               if (!(cl_options[md].flags & CL_JOINED))
508                 continue;
509
510               /* Is this switch valid for this front end?  */
511               if (!(cl_options[md].flags & lang_flag))
512                 {
513                   /* If subsequently we don't find a better match,
514                      return this and let the caller report it as a bad
515                      match.  */
516                   result = md;
517                   continue;
518                 }
519
520               /* Two scenarios remain: we have the switch's argument,
521                  or we match a longer option.  This can happen with
522                  -iwithprefix and -withprefixbefore.  The longest
523                  possible option match succeeds.
524
525                  Scan forwards, and return an exact match.  Otherwise
526                  return the longest valid option-accepting match (mx).
527                  This loops at most twice with current options.  */
528               mx = md;
529               for (md = md + 1; md < (size_t) N_OPTS; md++)
530                 {
531                   opt_len = cl_options[md].opt_len;
532                   if (strncmp (input, cl_options[md].opt_text, opt_len))
533                     break;
534                   if (input[opt_len] == '\0')
535                     return md;
536                   if (cl_options[md].flags & lang_flag
537                       && cl_options[md].flags & CL_JOINED)
538                     mx = md;
539                 }
540
541               return mx;
542             }
543         }
544     }
545
546   return result;
547 }
548
549 /* Defer option CODE with argument ARG.  */
550 static void
551 defer_opt (code, arg)
552      enum opt_code code;
553      const char *arg;
554 {
555   /* FIXME: this should be in c_common_init_options, which should take
556      argc and argv.  */
557   if (!deferred_opts)
558     {
559       extern int save_argc;
560       deferred_size = save_argc;
561       deferred_opts = (struct deferred_opt *)
562         xmalloc (deferred_size * sizeof (struct deferred_opt));
563     }
564
565   if (deferred_count == deferred_size)
566     abort ();
567
568   deferred_opts[deferred_count].code = code;
569   deferred_opts[deferred_count].arg = arg;
570   deferred_count++;
571 }
572
573 /* Common initialization before parsing options.  */
574 void
575 c_common_init_options (lang)
576      enum c_language_kind lang;
577 {
578 #ifdef HOST_EBCDIC
579   /* For non-ASCII hosts, the cl_options array needs to be sorted at
580      runtime.  */
581   qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp);
582 #endif
583 #if ENABLE_CHECKING
584  {
585   size_t i;
586
587   for (i = 1; i < N_OPTS; i++)
588     if (strcmp (cl_options[i - 1].opt_text, cl_options[i].opt_text) >= 0)
589       error ("options array incorrectly sorted: %s is before %s",
590              cl_options[i - 1].opt_text, cl_options[i].opt_text);
591  }
592 #endif
593
594   c_language = lang;
595   parse_in = cpp_create_reader (lang == clk_c ? CLK_GNUC89 : CLK_GNUCXX,
596                                 ident_hash);
597   cpp_opts = cpp_get_options (parse_in);
598   cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
599   if (flag_objc)
600     cpp_opts->objc = 1;
601
602   flag_const_strings = (lang == clk_cplusplus);
603   warn_pointer_arith = (lang == clk_cplusplus);
604 }
605
606 /* Handle one command-line option in (argc, argv).
607    Can be called multiple times, to handle multiple sets of options.
608    Returns number of strings consumed.  */
609 int
610 c_common_decode_option (argc, argv)
611      int argc;
612      char **argv;
613 {
614   static const int lang_flags[] = {CL_C_ONLY, CL_C, CL_CXX_ONLY, CL_CXX};
615   size_t opt_index;
616   const char *opt, *arg = 0;
617   char *dup = 0;
618   bool on = true;
619   int result = 0, lang_flag;
620   const struct cl_option *option;
621   enum opt_code code;
622
623   opt = argv[0];
624
625   /* Interpret "-" or a non-switch as a file name.  */
626   if (opt[0] != '-' || opt[1] == '\0')
627     {
628       if (!in_fname)
629         in_fname = opt;
630       else if (!out_fname)
631         out_fname = opt;
632       else
633         {
634           error ("too many filenames given.  Type %s --help for usage",
635                  progname);
636           return argc;
637         }
638
639       return 1;
640     }
641
642   /* Drop the "no-" from negative switches.  */
643   if ((opt[1] == 'W' || opt[1] == 'f')
644       && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
645     {
646       size_t len = strlen (opt) - 3;
647
648       dup = xmalloc (len + 1);
649       dup[0] = '-';
650       dup[1] = opt[1];
651       memcpy (dup + 2, opt + 5, len - 2 + 1);
652       opt = dup;
653       on = false;
654     }
655
656   /* Skip over '-'.  */
657   lang_flag = lang_flags[(c_language << 1) + flag_objc];
658   opt_index = find_opt (opt + 1, lang_flag);
659   if (opt_index == N_OPTS)
660     goto done;
661
662   result = 1;
663   option = &cl_options[opt_index];
664
665   /* Sort out any argument the switch takes.  */
666   if (option->flags & CL_ARG)
667     {
668       if (option->flags & CL_JOINED)
669         {
670           /* Have arg point to the original switch.  This is because
671              some code, such as disable_builtin_function, expects its
672              argument to be persistent until the program exits.  */
673           arg = argv[0] + cl_options[opt_index].opt_len + 1;
674           if (!on)
675             arg += strlen ("no-");
676         }
677
678       /* If we don't have an argument, and CL_SEPARATE, try the next
679          argument in the vector.  */
680       if (!arg || (*arg == '\0' && option->flags & CL_SEPARATE))
681         {
682           arg = argv[1];
683           result = 2;
684         }
685
686       if (!arg || *arg == '\0')
687         {
688           missing_arg (opt_index);
689           result = argc;
690           goto done;
691         }
692     }
693
694   /* Complain about the wrong language after we've swallowed any
695      necessary extra argument.  Eventually make this a hard error
696      after the call to find_opt, and return argc.  */
697   if (!(cl_options[opt_index].flags & lang_flag))
698     {
699       complain_wrong_lang (opt_index);
700       goto done;
701     }
702
703   switch (code = option->opt_code)
704     {
705     case N_OPTS: /* Shut GCC up.  */
706       break;
707
708     case OPT__help:
709       print_help ();
710       break;
711
712     case OPT__output_pch:
713       pch_file = arg;
714       break;
715
716     case OPT_A:
717       defer_opt (code, arg);
718       break;
719
720     case OPT_C:
721       cpp_opts->discard_comments = 0;
722       break;
723
724     case OPT_CC:
725       cpp_opts->discard_comments = 0;
726       cpp_opts->discard_comments_in_macro_exp = 0;
727       break;
728
729     case OPT_D:
730       defer_opt (code, arg);
731       break;
732
733     case OPT_E:
734       flag_preprocess_only = 1;
735       break;
736
737     case OPT_H:
738       cpp_opts->print_include_names = 1;
739       break;
740
741     case OPT_I:
742       if (strcmp (arg, "-"))
743         add_path (xstrdup (arg), BRACKET, 0);
744       else
745         {
746           if (quote_chain_split)
747             error ("-I- specified twice");
748           quote_chain_split = true;
749           split_quote_chain ();
750         }
751       break;
752
753     case OPT_M:
754     case OPT_MM:
755       /* When doing dependencies with -M or -MM, suppress normal
756          preprocessed output, but still do -dM etc. as software
757          depends on this.  Preprocessed output does occur if -MD, -MMD
758          or environment var dependency generation is used.  */
759       cpp_opts->deps.style = (code == OPT_M ? DEPS_SYSTEM: DEPS_USER);
760       flag_no_output = 1;
761       cpp_opts->inhibit_warnings = 1;
762       break;
763
764     case OPT_MD:
765     case OPT_MMD:
766       cpp_opts->deps.style = (code == OPT_MD ? DEPS_SYSTEM: DEPS_USER);
767       deps_file = arg;
768       break;
769
770     case OPT_MF:
771       deps_seen = true;
772       deps_file = arg;
773       break;
774
775     case OPT_MG:
776       deps_seen = true;
777       cpp_opts->deps.missing_files = true;
778       break;
779
780     case OPT_MP:
781       deps_seen = true;
782       cpp_opts->deps.phony_targets = true;
783       break;
784
785     case OPT_MQ:
786     case OPT_MT:
787       deps_seen = true;
788       defer_opt (code, arg);
789       break;
790
791     case OPT_P:
792       flag_no_line_commands = 1;
793       break;
794
795     case OPT_U:
796       defer_opt (code, arg);
797       break;
798
799     case OPT_Wabi:
800       warn_abi = on;
801       break;
802
803     case OPT_Wall:
804       set_Wunused (on);
805       set_Wformat (on);
806       set_Wimplicit (on);
807       warn_char_subscripts = on;
808       warn_missing_braces = on;
809       warn_parentheses = on;
810       warn_return_type = on;
811       warn_sequence_point = on; /* Was C only.  */
812       if (c_language == clk_cplusplus)
813         warn_sign_compare = on;
814       warn_switch = on;
815       warn_strict_aliasing = on;
816       
817       /* Only warn about unknown pragmas that are not in system
818          headers.  */                                        
819       warn_unknown_pragmas = on;
820
821       /* We save the value of warn_uninitialized, since if they put
822          -Wuninitialized on the command line, we need to generate a
823          warning about not using it without also specifying -O.  */
824       if (warn_uninitialized != 1)
825         warn_uninitialized = (on ? 2 : 0);
826
827       if (c_language == clk_c)
828         /* We set this to 2 here, but 1 in -Wmain, so -ffreestanding
829            can turn it off only if it's not explicit.  */
830         warn_main = on * 2;
831       else
832         {
833           /* C++-specific warnings.  */
834           warn_nonvdtor = on;
835           warn_reorder = on;
836           warn_nontemplate_friend = on;
837         }
838
839       cpp_opts->warn_trigraphs = on;
840       cpp_opts->warn_comments = on;
841       cpp_opts->warn_num_sign_change = on;
842       cpp_opts->warn_multichar = on;    /* Was C++ only.  */
843       break;
844
845     case OPT_Wbad_function_cast:
846       warn_bad_function_cast = on;
847       break;
848
849     case OPT_Wcast_qual:
850       warn_cast_qual = on;
851       break;
852
853     case OPT_Wchar_subscripts:
854       warn_char_subscripts = on;
855       break;
856
857     case OPT_Wcomment:
858     case OPT_Wcomments:
859       cpp_opts->warn_comments = on;
860       break;
861
862     case OPT_Wconversion:
863       warn_conversion = on;
864       break;
865
866     case OPT_Wctor_dtor_privacy:
867       warn_ctor_dtor_privacy = on;
868       break;
869
870     case OPT_Wdeprecated:
871       warn_deprecated = on;
872       cpp_opts->warn_deprecated = on;
873       break;
874
875     case OPT_Wdiv_by_zero:
876       warn_div_by_zero = on;
877       break;
878
879     case OPT_Weffcxx:
880       warn_ecpp = on;
881       break;
882
883     case OPT_Wendif_labels:
884       cpp_opts->warn_endif_labels = on;
885       break;
886
887     case OPT_Werror:
888       cpp_opts->warnings_are_errors = on;
889       break;
890
891     case OPT_Werror_implicit_function_decl:
892       if (!on)
893         result = 0;
894       else
895         mesg_implicit_function_declaration = 2;
896       break;
897
898     case OPT_Wfloat_equal:
899       warn_float_equal = on;
900       break;
901
902     case OPT_Wformat:
903       set_Wformat (on);
904       break;
905
906     case OPT_Wformat_eq:
907       set_Wformat (atoi (arg));
908       break;
909
910     case OPT_Wformat_extra_args:
911       warn_format_extra_args = on;
912       break;
913
914     case OPT_Wformat_nonliteral:
915       warn_format_nonliteral = on;
916       break;
917
918     case OPT_Wformat_security:
919       warn_format_security = on;
920       break;
921
922     case OPT_Wformat_y2k:
923       warn_format_y2k = on;
924       break;
925
926     case OPT_Wformat_zero_length:
927       warn_format_zero_length = on;
928       break;
929
930     case OPT_Wimplicit:
931       set_Wimplicit (on);
932       break;
933
934     case OPT_Wimplicit_function_decl:
935       mesg_implicit_function_declaration = on;
936       break;
937
938     case OPT_Wimplicit_int:
939       warn_implicit_int = on;
940       break;
941
942     case OPT_Wimport:
943       cpp_opts->warn_import = on;
944       break;
945
946     case OPT_Winvalid_offsetof:
947       warn_invalid_offsetof = on;
948       break;
949
950     case OPT_Winvalid_pch:
951       cpp_opts->warn_invalid_pch = on;
952       break;
953
954     case OPT_Wlong_long:
955       warn_long_long = on;
956       break;
957
958     case OPT_Wmain:
959       if (on)
960         warn_main = 1;
961       else
962         warn_main = -1;
963       break;
964
965     case OPT_Wmissing_braces:
966       warn_missing_braces = on;
967       break;
968
969     case OPT_Wmissing_declarations:
970       warn_missing_declarations = on;
971       break;
972
973     case OPT_Wmissing_format_attribute:
974       warn_missing_format_attribute = on;
975       break;
976
977     case OPT_Wmissing_prototypes:
978       warn_missing_prototypes = on;
979       break;
980
981     case OPT_Wmultichar:
982       cpp_opts->warn_multichar = on;
983       break;
984
985     case OPT_Wnested_externs:
986       warn_nested_externs = on;
987       break;
988
989     case OPT_Wnon_template_friend:
990       warn_nontemplate_friend = on;
991       break;
992
993     case OPT_Wnon_virtual_dtor:
994       warn_nonvdtor = on;
995       break;
996
997     case OPT_Wnonnull:
998       warn_nonnull = on;
999       break;
1000
1001     case OPT_Wold_style_cast:
1002       warn_old_style_cast = on;
1003       break;
1004
1005     case OPT_Woverloaded_virtual:
1006       warn_overloaded_virtual = on;
1007       break;
1008
1009     case OPT_Wparentheses:
1010       warn_parentheses = on;
1011       break;
1012
1013     case OPT_Wpmf_conversions:
1014       warn_pmf2ptr = on;
1015       break;
1016
1017     case OPT_Wpointer_arith:
1018       warn_pointer_arith = on;
1019       break;
1020
1021     case OPT_Wprotocol:
1022       warn_protocol = on;
1023       break;
1024
1025     case OPT_Wselector:
1026       warn_selector = on;
1027       break;
1028
1029     case OPT_Wredundant_decls:
1030       warn_redundant_decls = on;
1031       break;
1032
1033     case OPT_Wreorder:
1034       warn_reorder = on;
1035       break;
1036
1037     case OPT_Wreturn_type:
1038       warn_return_type = on;
1039       break;
1040
1041     case OPT_Wsequence_point:
1042       warn_sequence_point = on;
1043       break;
1044
1045     case OPT_Wsign_compare:
1046       warn_sign_compare = on;
1047       break;
1048
1049     case OPT_Wsign_promo:
1050       warn_sign_promo = on;
1051       break;
1052
1053     case OPT_Wstrict_prototypes:
1054       if (!on && c_language == clk_cplusplus)
1055         warning ("-Wno-strict-prototypes is not supported in C++");
1056       else
1057         warn_strict_prototypes = on;
1058       break;
1059
1060     case OPT_Wsynth:
1061       warn_synth = on;
1062       break;
1063
1064     case OPT_Wsystem_headers:
1065       cpp_opts->warn_system_headers = on;
1066       break;
1067
1068     case OPT_Wtraditional:
1069       warn_traditional = on;
1070       cpp_opts->warn_traditional = on;
1071       break;
1072
1073     case OPT_Wtrigraphs:
1074       cpp_opts->warn_trigraphs = on;
1075       break;
1076
1077     case OPT_Wundeclared_selector:
1078       warn_undeclared_selector = on;
1079       break;
1080
1081     case OPT_Wundef:
1082       cpp_opts->warn_undef = on;
1083       break;
1084
1085     case OPT_Wunknown_pragmas:
1086       /* Set to greater than 1, so that even unknown pragmas in
1087          system headers will be warned about.  */  
1088       warn_unknown_pragmas = on * 2;
1089       break;
1090
1091     case OPT_Wunused_macros:
1092       warn_unused_macros = on;
1093       break;
1094
1095     case OPT_Wwrite_strings:
1096       if (c_language == clk_c)
1097         flag_const_strings = on;
1098       else
1099         warn_write_strings = on;
1100       break;
1101       
1102     case OPT_ansi:
1103       if (c_language == clk_c)
1104         set_std_c89 (false, true);
1105       else
1106         set_std_cxx98 (true);
1107       break;
1108
1109     case OPT_d:
1110       handle_OPT_d (arg);
1111       break;
1112
1113     case OPT_fcond_mismatch:
1114       if (c_language == clk_c)
1115         {
1116           flag_cond_mismatch = on;
1117           break;
1118         }
1119       /* Fall through.  */
1120
1121     case OPT_fall_virtual:
1122     case OPT_fenum_int_equiv:
1123     case OPT_fguiding_decls:
1124     case OPT_fhonor_std:
1125     case OPT_fhuge_objects:
1126     case OPT_flabels_ok:
1127     case OPT_fname_mangling:
1128     case OPT_fnew_abi:
1129     case OPT_fnonnull_objects:
1130     case OPT_fsquangle:
1131     case OPT_fstrict_prototype:
1132     case OPT_fthis_is_variable:
1133     case OPT_fvtable_thunks:
1134     case OPT_fxref:
1135       warning ("switch \"%s\" is no longer supported", argv[0]);
1136       break;
1137
1138     case OPT_fabi_version:
1139       flag_abi_version = read_integral_parameter (arg, argv[0], 1);
1140       break;
1141
1142     case OPT_faccess_control:
1143       flag_access_control = on;
1144       break;
1145
1146     case OPT_falt_external_templates:
1147       flag_alt_external_templates = on;
1148       if (on)
1149         flag_external_templates = true;
1150     cp_deprecated:
1151       warning ("switch \"%s\" is deprecated, please see documentation for details", argv[0]);
1152       break;
1153
1154     case OPT_fasm:
1155       flag_no_asm = !on;
1156       break;
1157
1158     case OPT_fbuiltin:
1159       flag_no_builtin = !on;
1160       break;
1161
1162     case OPT_fbuiltin_:
1163       if (on)
1164         result = 0;
1165       else
1166         disable_builtin_function (arg);
1167       break;
1168
1169     case OPT_fdollars_in_identifiers:
1170       cpp_opts->dollars_in_ident = on;
1171       break;
1172
1173     case OPT_fdump:
1174       if (!on || !dump_switch_p (argv[0] + strlen ("-f")))
1175         result = 0;
1176       break;
1177
1178     case OPT_ffreestanding:
1179       on = !on;
1180       /* Fall through...  */
1181     case OPT_fhosted:
1182       flag_hosted = on;
1183       flag_no_builtin = !on;
1184       /* warn_main will be 2 if set by -Wall, 1 if set by -Wmain */
1185       if (!on && warn_main == 2)
1186         warn_main = 0;
1187       break;
1188
1189     case OPT_fshort_double:
1190       flag_short_double = on;
1191       break;
1192
1193     case OPT_fshort_enums:
1194       flag_short_enums = on;
1195       break;
1196
1197     case OPT_fshort_wchar:
1198       flag_short_wchar = on;
1199       break;
1200
1201     case OPT_fsigned_bitfields:
1202       flag_signed_bitfields = on;
1203       explicit_flag_signed_bitfields = 1;
1204       break;
1205
1206     case OPT_fsigned_char:
1207       flag_signed_char = on;
1208       break;
1209
1210     case OPT_funsigned_bitfields:
1211       flag_signed_bitfields = !on;
1212       explicit_flag_signed_bitfields = 1;
1213       break;
1214
1215     case OPT_funsigned_char:
1216       flag_signed_char = !on;
1217       break;
1218
1219     case OPT_fcheck_new:
1220       flag_check_new = on;
1221       break;
1222
1223     case OPT_fconserve_space:
1224       flag_conserve_space = on;
1225       break;
1226
1227     case OPT_fconst_strings:
1228       flag_const_strings = on;
1229       break;
1230
1231     case OPT_fconstant_string_class:
1232       constant_string_class_name = arg;
1233       break;
1234
1235     case OPT_fdefault_inline:
1236       flag_default_inline = on;
1237       break;
1238
1239     case OPT_felide_constructors:
1240       flag_elide_constructors = on;
1241       break;
1242
1243     case OPT_fenforce_eh_specs:
1244       flag_enforce_eh_specs = on;
1245       break;
1246
1247     case OPT_fexternal_templates:
1248       flag_external_templates = on;
1249       goto cp_deprecated;
1250
1251     case OPT_ffixed_form:
1252     case OPT_ffixed_line_length:
1253       /* Fortran front end options ignored when preprocessing only.  */
1254       if (flag_preprocess_only)
1255         result = -1;
1256       break;
1257
1258     case OPT_ffor_scope:
1259       flag_new_for_scope = on;
1260       break;
1261
1262     case OPT_fgnu_keywords:
1263       flag_no_gnu_keywords = !on;
1264       break;
1265
1266     case OPT_fgnu_runtime:
1267       flag_next_runtime = !on;
1268       break;
1269
1270     case OPT_fhandle_exceptions:
1271       warning ("-fhandle-exceptions has been renamed to -fexceptions (and is now on by default)");
1272       flag_exceptions = on;
1273       break;
1274
1275     case OPT_fimplement_inlines:
1276       flag_implement_inlines = on;
1277       break;
1278
1279     case OPT_fimplicit_inline_templates:
1280       flag_implicit_inline_templates = on;
1281       break;
1282
1283     case OPT_fimplicit_templates:
1284       flag_implicit_templates = on;
1285       break;
1286
1287     case OPT_fms_extensions:
1288       flag_ms_extensions = on;
1289       break;
1290
1291     case OPT_fnext_runtime:
1292       flag_next_runtime = on;
1293       break;
1294
1295     case OPT_fnonansi_builtins:
1296       flag_no_nonansi_builtin = !on;
1297       break;
1298
1299     case OPT_foperator_names:
1300       cpp_opts->operator_names = on;
1301       break;
1302
1303     case OPT_foptional_diags:
1304       flag_optional_diags = on;
1305       break;
1306
1307     case OPT_fpch_deps:
1308       cpp_opts->restore_pch_deps = on;
1309       break;
1310
1311     case OPT_fpermissive:
1312       flag_permissive = on;
1313       break;
1314
1315     case OPT_fpreprocessed:
1316       cpp_opts->preprocessed = on;
1317       break;
1318
1319     case OPT_frepo:
1320       flag_use_repository = on;
1321       if (on)
1322         flag_implicit_templates = 0;
1323       break;
1324
1325     case OPT_frtti:
1326       flag_rtti = on;
1327       break;
1328
1329     case OPT_fshow_column:
1330       cpp_opts->show_column = on;
1331       break;
1332
1333     case OPT_fstats:
1334       flag_detailed_statistics = on;
1335       break;
1336
1337     case OPT_ftabstop:
1338       /* Don't recognize -fno-tabstop=.  */
1339       if (!on)
1340         return 0;
1341
1342       /* It is documented that we silently ignore silly values.  */
1343         {
1344           char *endptr;
1345           long tabstop = strtol (arg, &endptr, 10);
1346           if (*endptr == '\0' && tabstop >= 1 && tabstop <= 100)
1347             cpp_opts->tabstop = tabstop;
1348         }
1349       break;
1350
1351     case OPT_ftemplate_depth:
1352       max_tinst_depth = read_integral_parameter (arg, argv[0], 0);
1353       break;
1354
1355     case OPT_fvtable_gc:
1356       flag_vtable_gc = on;
1357       break;
1358
1359     case OPT_fuse_cxa_atexit:
1360       flag_use_cxa_atexit = on;
1361       break;
1362
1363     case OPT_fweak:
1364       flag_weak = on;
1365       break;
1366
1367     case OPT_gen_decls:
1368       flag_gen_declaration = 1;
1369       break;
1370
1371     case OPT_idirafter:
1372       add_path (xstrdup (arg), AFTER, 0);
1373       break;
1374
1375     case OPT_imacros:
1376     case OPT_include:
1377       defer_opt (code, arg);
1378       break;
1379
1380     case OPT_iprefix:
1381       iprefix = arg;
1382       break;
1383
1384     case OPT_isysroot:
1385       sysroot = arg;
1386       break;
1387
1388     case OPT_isystem:
1389       add_path (xstrdup (arg), SYSTEM, 0);
1390       break;
1391
1392     case OPT_iwithprefix:
1393       add_prefixed_path (arg, SYSTEM);
1394       break;
1395
1396     case OPT_iwithprefixbefore:
1397       add_prefixed_path (arg, BRACKET);
1398       break;
1399
1400     case OPT_lang_asm:
1401       cpp_set_lang (parse_in, CLK_ASM);
1402       cpp_opts->dollars_in_ident = false;
1403       break;
1404
1405     case OPT_lang_objc:
1406       cpp_opts->objc = 1;
1407       break;
1408
1409     case OPT_nostdinc:
1410       std_inc = false;
1411       break;
1412
1413     case OPT_nostdincplusplus:
1414       std_cxx_inc = false;
1415       break;
1416
1417     case OPT_o:
1418       if (!out_fname)
1419         out_fname = arg;
1420       else
1421         {
1422           error ("output filename specified twice");
1423           result = argc;
1424         }
1425       break;
1426
1427       /* We need to handle the -pedantic switches here, rather than in
1428          c_common_post_options, so that a subsequent -Wno-endif-labels
1429          is not overridden.  */
1430     case OPT_pedantic_errors:
1431       cpp_opts->pedantic_errors = 1;
1432       /* fall through */
1433     case OPT_pedantic:
1434       cpp_opts->pedantic = 1;
1435       cpp_opts->warn_endif_labels = 1;
1436       break;
1437
1438     case OPT_print_objc_runtime_info:
1439       print_struct_values = 1;
1440       break;
1441
1442     case OPT_remap:
1443       cpp_opts->remap = 1;
1444       break;
1445
1446     case OPT_std_cplusplus98:
1447     case OPT_std_gnuplusplus98:
1448       set_std_cxx98 (code == OPT_std_cplusplus98 /* ISO */);
1449       break;
1450
1451     case OPT_std_c89:
1452     case OPT_std_iso9899_1990:
1453     case OPT_std_iso9899_199409:
1454       set_std_c89 (code == OPT_std_iso9899_199409 /* c94 */, true /* ISO */);
1455       break;
1456
1457     case OPT_std_gnu89:
1458       set_std_c89 (false /* c94 */, false /* ISO */);
1459       break;
1460
1461     case OPT_std_c99:
1462     case OPT_std_c9x:
1463     case OPT_std_iso9899_1999:
1464     case OPT_std_iso9899_199x:
1465       set_std_c99 (true /* ISO */);
1466       break;
1467
1468     case OPT_std_gnu99:
1469     case OPT_std_gnu9x:
1470       set_std_c99 (false /* ISO */);
1471       break;
1472
1473     case OPT_trigraphs:
1474       cpp_opts->trigraphs = 1;
1475       break;
1476
1477     case OPT_traditional_cpp:
1478       cpp_opts->traditional = 1;
1479       break;
1480
1481     case OPT_undef:
1482       flag_undef = 1;
1483       break;
1484
1485     case OPT_w:
1486       cpp_opts->inhibit_warnings = 1;
1487       break;
1488
1489     case OPT_v:
1490       verbose = true;
1491       break;
1492     }
1493
1494  done:
1495   if (dup)
1496     free (dup);
1497   return result;
1498 }
1499
1500 /* Post-switch processing.  */
1501 bool
1502 c_common_post_options (pfilename)
1503      const char **pfilename;
1504 {
1505   /* Canonicalize the input and output filenames.  */
1506   if (in_fname == NULL || !strcmp (in_fname, "-"))
1507     in_fname = "";
1508
1509   if (out_fname == NULL || !strcmp (out_fname, "-"))
1510     out_fname = "";
1511
1512   if (cpp_opts->deps.style == DEPS_NONE)
1513     check_deps_environment_vars ();
1514
1515   handle_deferred_opts ();
1516
1517   sanitize_cpp_opts ();
1518
1519   register_include_chains (parse_in, sysroot, iprefix,
1520                            std_inc, std_cxx_inc && c_language == clk_cplusplus,
1521                            verbose);
1522
1523   flag_inline_trees = 1;
1524
1525   /* Use tree inlining if possible.  Function instrumentation is only
1526      done in the RTL level, so we disable tree inlining.  */
1527   if (! flag_instrument_function_entry_exit)
1528     {
1529       if (!flag_no_inline)
1530         flag_no_inline = 1;
1531       if (flag_inline_functions)
1532         {
1533           flag_inline_trees = 2;
1534           flag_inline_functions = 0;
1535         }
1536     }
1537
1538   /* -Wextra implies -Wsign-compare, but not if explicitly
1539       overridden.  */
1540   if (warn_sign_compare == -1)
1541     warn_sign_compare = extra_warnings;
1542
1543   /* Special format checking options don't work without -Wformat; warn if
1544      they are used.  */
1545   if (warn_format_y2k && !warn_format)
1546     warning ("-Wformat-y2k ignored without -Wformat");
1547   if (warn_format_extra_args && !warn_format)
1548     warning ("-Wformat-extra-args ignored without -Wformat");
1549   if (warn_format_zero_length && !warn_format)
1550     warning ("-Wformat-zero-length ignored without -Wformat");
1551   if (warn_format_nonliteral && !warn_format)
1552     warning ("-Wformat-nonliteral ignored without -Wformat");
1553   if (warn_format_security && !warn_format)
1554     warning ("-Wformat-security ignored without -Wformat");
1555   if (warn_missing_format_attribute && !warn_format)
1556     warning ("-Wmissing-format-attribute ignored without -Wformat");
1557
1558   if (flag_preprocess_only)
1559     {
1560       /* Open the output now.  We must do so even if flag_no_output is
1561          on, because there may be other output than from the actual
1562          preprocessing (e.g. from -dM).  */
1563       if (out_fname[0] == '\0')
1564         out_stream = stdout;
1565       else
1566         out_stream = fopen (out_fname, "w");
1567
1568       if (out_stream == NULL)
1569         {
1570           fatal_error ("opening output file %s: %m", out_fname);
1571           return false;
1572         }
1573
1574       init_pp_output (out_stream);
1575     }
1576   else
1577     {
1578       init_c_lex ();
1579
1580       /* Yuk.  WTF is this?  I do know ObjC relies on it somewhere.  */
1581       input_line = 0;
1582     }
1583
1584   cpp_get_callbacks (parse_in)->file_change = cb_file_change;
1585
1586   /* NOTE: we use in_fname here, not the one supplied.  */
1587   *pfilename = cpp_read_main_file (parse_in, in_fname);
1588
1589   saved_lineno = input_line;
1590   input_line = 0;
1591
1592   /* If an error has occurred in cpplib, note it so we fail
1593      immediately.  */
1594   errorcount += cpp_errors (parse_in);
1595
1596   return flag_preprocess_only;
1597 }
1598
1599 /* Front end initialization common to C, ObjC and C++.  */
1600 bool
1601 c_common_init ()
1602 {
1603   input_line = saved_lineno;
1604
1605   /* Set up preprocessor arithmetic.  Must be done after call to
1606      c_common_nodes_and_builtins for type nodes to be good.  */
1607   cpp_opts->precision = TYPE_PRECISION (intmax_type_node);
1608   cpp_opts->char_precision = TYPE_PRECISION (char_type_node);
1609   cpp_opts->int_precision = TYPE_PRECISION (integer_type_node);
1610   cpp_opts->wchar_precision = TYPE_PRECISION (wchar_type_node);
1611   cpp_opts->unsigned_wchar = TREE_UNSIGNED (wchar_type_node);
1612   cpp_opts->EBCDIC = TARGET_EBCDIC;
1613
1614   if (flag_preprocess_only)
1615     {
1616       finish_options ();
1617       preprocess_file (parse_in);
1618       return false;
1619     }
1620
1621   /* Has to wait until now so that cpplib has its hash table.  */
1622   init_pragma ();
1623
1624   return true;
1625 }
1626
1627 /* A thin wrapper around the real parser that initializes the 
1628    integrated preprocessor after debug output has been initialized.
1629    Also, make sure the start_source_file debug hook gets called for
1630    the primary source file.  */
1631 void
1632 c_common_parse_file (set_yydebug)
1633      int set_yydebug ATTRIBUTE_UNUSED;
1634 {
1635 #if YYDEBUG != 0
1636   yydebug = set_yydebug;
1637 #else
1638   warning ("YYDEBUG not defined");
1639 #endif
1640
1641   (*debug_hooks->start_source_file) (input_line, input_filename);
1642   finish_options();
1643   pch_init();
1644   yyparse ();
1645   free_parser_stacks ();
1646 }
1647
1648 /* Common finish hook for the C, ObjC and C++ front ends.  */
1649 void
1650 c_common_finish ()
1651 {
1652   FILE *deps_stream = NULL;
1653
1654   if (cpp_opts->deps.style != DEPS_NONE)
1655     {
1656       /* If -M or -MM was seen without -MF, default output to the
1657          output stream.  */
1658       if (!deps_file)
1659         deps_stream = out_stream;
1660       else
1661         {
1662           deps_stream = fopen (deps_file, deps_append ? "a": "w");
1663           if (!deps_stream)
1664             fatal_error ("opening dependency file %s: %m", deps_file);
1665         }
1666     }
1667
1668   /* For performance, avoid tearing down cpplib's internal structures
1669      with cpp_destroy ().  */
1670   errorcount += cpp_finish (parse_in, deps_stream);
1671
1672   if (deps_stream && deps_stream != out_stream
1673       && (ferror (deps_stream) || fclose (deps_stream)))
1674     fatal_error ("closing dependency file %s: %m", deps_file);
1675
1676   if (out_stream && (ferror (out_stream) || fclose (out_stream)))
1677     fatal_error ("when writing output to %s: %m", out_fname);
1678 }
1679
1680 /* Either of two environment variables can specify output of
1681    dependencies.  Their value is either "OUTPUT_FILE" or "OUTPUT_FILE
1682    DEPS_TARGET", where OUTPUT_FILE is the file to write deps info to
1683    and DEPS_TARGET is the target to mention in the deps.  They also
1684    result in dependency information being appended to the output file
1685    rather than overwriting it, and like Sun's compiler
1686    SUNPRO_DEPENDENCIES suppresses the dependency on the main file.  */
1687 static void
1688 check_deps_environment_vars ()
1689 {
1690   char *spec;
1691
1692   GET_ENVIRONMENT (spec, "DEPENDENCIES_OUTPUT");
1693   if (spec)
1694     cpp_opts->deps.style = DEPS_USER;
1695   else
1696     {
1697       GET_ENVIRONMENT (spec, "SUNPRO_DEPENDENCIES");
1698       if (spec)
1699         {
1700           cpp_opts->deps.style = DEPS_SYSTEM;
1701           cpp_opts->deps.ignore_main_file = true;
1702         }
1703     }
1704
1705   if (spec)
1706     {
1707       /* Find the space before the DEPS_TARGET, if there is one.  */
1708       char *s = strchr (spec, ' ');
1709       if (s)
1710         {
1711           /* Let the caller perform MAKE quoting.  */
1712           defer_opt (OPT_MT, s + 1);
1713           *s = '\0';
1714         }
1715
1716       /* Command line -MF overrides environment variables and default.  */
1717       if (!deps_file)
1718         deps_file = spec;
1719
1720       deps_append = 1;
1721     }
1722 }
1723
1724 /* Handle deferred command line switches.  */
1725 static void
1726 handle_deferred_opts ()
1727 {
1728   size_t i;
1729
1730   for (i = 0; i < deferred_count; i++)
1731     {
1732       struct deferred_opt *opt = &deferred_opts[i];
1733
1734       if (opt->code == OPT_MT || opt->code == OPT_MQ)
1735         cpp_add_dependency_target (parse_in, opt->arg, opt->code == OPT_MQ);
1736     }
1737 }
1738
1739 /* These settings are appropriate for GCC, but not necessarily so for
1740    cpplib as a library.  */
1741 static void
1742 sanitize_cpp_opts ()
1743 {
1744   /* If we don't know what style of dependencies to output, complain
1745      if any other dependency switches have been given.  */
1746   if (deps_seen && cpp_opts->deps.style == DEPS_NONE)
1747     error ("to generate dependencies you must specify either -M or -MM");
1748
1749   /* -dM and dependencies suppress normal output; do it here so that
1750      the last -d[MDN] switch overrides earlier ones.  */
1751   if (flag_dump_macros == 'M')
1752     flag_no_output = 1;
1753
1754   /* Disable -dD, -dN and -dI if normal output is suppressed.  Allow
1755      -dM since at least glibc relies on -M -dM to work.  */
1756   if (flag_no_output)
1757     {
1758       if (flag_dump_macros != 'M')
1759         flag_dump_macros = 0;
1760       flag_dump_includes = 0;
1761     }
1762
1763   cpp_opts->unsigned_char = !flag_signed_char;
1764   cpp_opts->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;
1765
1766   /* We want -Wno-long-long to override -pedantic -std=non-c99
1767      and/or -Wtraditional, whatever the ordering.  */
1768   cpp_opts->warn_long_long
1769     = warn_long_long && ((!flag_isoc99 && pedantic) || warn_traditional);
1770 }
1771
1772 /* Add include path with a prefix at the front of its name.  */
1773 static void
1774 add_prefixed_path (suffix, chain)
1775      const char *suffix;
1776      size_t chain;
1777 {
1778   char *path;
1779   const char *prefix;
1780   size_t prefix_len, suffix_len;
1781
1782   suffix_len = strlen (suffix);
1783   prefix     = iprefix ? iprefix : cpp_GCC_INCLUDE_DIR;
1784   prefix_len = iprefix ? strlen (iprefix) : cpp_GCC_INCLUDE_DIR_len;
1785
1786   path = xmalloc (prefix_len + suffix_len + 1);
1787   memcpy (path, prefix, prefix_len);
1788   memcpy (path + prefix_len, suffix, suffix_len);
1789   path[prefix_len + suffix_len] = '\0';
1790
1791   add_path (path, chain, 0);
1792 }
1793
1794 /* Handle -D, -U, -A, -imacros, and the first -include.  */
1795 static void
1796 finish_options ()
1797 {
1798   if (!cpp_opts->preprocessed)
1799     {
1800       size_t i;
1801
1802       cpp_change_file (parse_in, LC_RENAME, _("<built-in>"));
1803       cpp_init_builtins (parse_in, flag_hosted);
1804       c_cpp_builtins (parse_in);
1805       cpp_change_file (parse_in, LC_RENAME, _("<command line>"));
1806       for (i = 0; i < deferred_count; i++)
1807         {
1808           struct deferred_opt *opt = &deferred_opts[i];
1809
1810           if (opt->code == OPT_D)
1811             cpp_define (parse_in, opt->arg);
1812           else if (opt->code == OPT_U)
1813             cpp_undef (parse_in, opt->arg);
1814           else if (opt->code == OPT_A)
1815             {
1816               if (opt->arg[0] == '-')
1817                 cpp_unassert (parse_in, opt->arg + 1);
1818               else
1819                 cpp_assert (parse_in, opt->arg);
1820             }
1821         }
1822
1823       /* Handle -imacros after -D and -U.  */
1824       for (i = 0; i < deferred_count; i++)
1825         {
1826           struct deferred_opt *opt = &deferred_opts[i];
1827
1828           if (opt->code == OPT_imacros
1829               && cpp_push_include (parse_in, opt->arg))
1830             cpp_scan_nooutput (parse_in);
1831         }
1832     }
1833
1834   push_command_line_include ();
1835 }
1836
1837 /* Give CPP the next file given by -include, if any.  */
1838 static void
1839 push_command_line_include ()
1840 {
1841   if (cpp_opts->preprocessed)
1842     return;
1843     
1844   while (include_cursor < deferred_count)
1845     {
1846       struct deferred_opt *opt = &deferred_opts[include_cursor++];
1847       
1848       if (opt->code == OPT_include && cpp_push_include (parse_in, opt->arg))
1849         return;
1850     }
1851
1852   if (include_cursor == deferred_count)
1853     {
1854       /* Restore the line map from <command line>.  */
1855       cpp_change_file (parse_in, LC_RENAME, main_input_filename);
1856       /* -Wunused-macros should only warn about macros defined hereafter.  */
1857       cpp_opts->warn_unused_macros = warn_unused_macros;
1858       include_cursor++;
1859     }
1860 }
1861
1862 /* File change callback.  Has to handle -include files.  */
1863 static void
1864 cb_file_change (pfile, new_map)
1865      cpp_reader *pfile ATTRIBUTE_UNUSED;
1866      const struct line_map *new_map;
1867 {
1868   if (flag_preprocess_only)
1869     pp_file_change (new_map);
1870   else
1871     fe_file_change (new_map);
1872
1873   if (new_map->reason == LC_LEAVE && MAIN_FILE_P (new_map))
1874     push_command_line_include ();
1875 }
1876
1877 /* Set the C 89 standard (with 1994 amendments if C94, without GNU
1878    extensions if ISO).  There is no concept of gnu94.  */
1879 static void
1880 set_std_c89 (c94, iso)
1881      int c94, iso;
1882 {
1883   cpp_set_lang (parse_in, c94 ? CLK_STDC94: iso ? CLK_STDC89: CLK_GNUC89);
1884   flag_iso = iso;
1885   flag_no_asm = iso;
1886   flag_no_gnu_keywords = iso;
1887   flag_no_nonansi_builtin = iso;
1888   flag_noniso_default_format_attributes = !iso;
1889   flag_isoc94 = c94;
1890   flag_isoc99 = 0;
1891   flag_writable_strings = 0;
1892 }
1893
1894 /* Set the C 99 standard (without GNU extensions if ISO).  */
1895 static void
1896 set_std_c99 (iso)
1897      int iso;
1898 {
1899   cpp_set_lang (parse_in, iso ? CLK_STDC99: CLK_GNUC99);
1900   flag_no_asm = iso;
1901   flag_no_nonansi_builtin = iso;
1902   flag_noniso_default_format_attributes = !iso;
1903   flag_iso = iso;
1904   flag_isoc99 = 1;
1905   flag_isoc94 = 1;
1906   flag_writable_strings = 0;
1907 }
1908
1909 /* Set the C++ 98 standard (without GNU extensions if ISO).  */
1910 static void
1911 set_std_cxx98 (iso)
1912      int iso;
1913 {
1914   cpp_set_lang (parse_in, iso ? CLK_CXX98: CLK_GNUCXX);
1915   flag_no_gnu_keywords = iso;
1916   flag_no_nonansi_builtin = iso;
1917   flag_noniso_default_format_attributes = !iso;
1918   flag_iso = iso;
1919 }
1920
1921 /* Handle setting implicit to ON.  */
1922 static void
1923 set_Wimplicit (on)
1924      int on;
1925 {
1926   warn_implicit = on;
1927   warn_implicit_int = on;
1928   if (on)
1929     {
1930       if (mesg_implicit_function_declaration != 2)
1931         mesg_implicit_function_declaration = 1;
1932     }
1933   else
1934     mesg_implicit_function_declaration = 0;
1935 }
1936
1937 /* Args to -d specify what to dump.  Silently ignore
1938    unrecognized options; they may be aimed at toplev.c.  */
1939 static void
1940 handle_OPT_d (arg)
1941      const char *arg;
1942 {
1943   char c;
1944
1945   while ((c = *arg++) != '\0')
1946     switch (c)
1947       {
1948       case 'M':                 /* Dump macros only.  */
1949       case 'N':                 /* Dump names.  */
1950       case 'D':                 /* Dump definitions.  */
1951         flag_dump_macros = c;
1952         break;
1953
1954       case 'I':
1955         flag_dump_includes = 1;
1956         break;
1957       }
1958 }
1959
1960 /* Write a slash-separated list of languages in FLAGS to BUF.  */
1961 static void
1962 write_langs (buf, flags)
1963      char *buf;
1964      int flags;
1965 {
1966   *buf = '\0';
1967   if (flags & CL_C_ONLY)
1968     strcat (buf, "C");
1969   if (flags & CL_OBJC_ONLY)
1970     {
1971       if (*buf)
1972         strcat (buf, "/");
1973       strcat (buf, "ObjC");
1974     }
1975   if (flags & CL_CXX_ONLY)
1976     {
1977       if (*buf)
1978         strcat (buf, "/");
1979       strcat (buf, "C++");
1980     }
1981 }
1982
1983 /* Complain that switch OPT_INDEX does not apply to this front end.  */
1984 static void
1985 complain_wrong_lang (opt_index)
1986      size_t opt_index;
1987 {
1988   char ok_langs[60], bad_langs[60];
1989   int ok_flags = cl_options[opt_index].flags;
1990
1991   write_langs (ok_langs, ok_flags);
1992   write_langs (bad_langs, ~ok_flags);
1993   warning ("\"-%s\" is valid for %s but not for %s",
1994            cl_options[opt_index].opt_text, ok_langs, bad_langs);
1995 }
1996
1997 /* Handle --help output.  */
1998 static void
1999 print_help ()
2000 {
2001   /* To keep the lines from getting too long for some compilers, limit
2002      to about 500 characters (6 lines) per chunk.  */
2003   fputs (_("\
2004 Switches:\n\
2005   -include <file>           Include the contents of <file> before other files\n\
2006   -imacros <file>           Accept definition of macros in <file>\n\
2007   -iprefix <path>           Specify <path> as a prefix for next two options\n\
2008   -iwithprefix <dir>        Add <dir> to the end of the system include path\n\
2009   -iwithprefixbefore <dir>  Add <dir> to the end of the main include path\n\
2010   -isystem <dir>            Add <dir> to the start of the system include path\n\
2011 "), stdout);
2012   fputs (_("\
2013   -idirafter <dir>          Add <dir> to the end of the system include path\n\
2014   -I <dir>                  Add <dir> to the end of the main include path\n\
2015   -I-                       Fine-grained include path control; see info docs\n\
2016   -nostdinc                 Do not search system include directories\n\
2017                              (dirs specified with -isystem will still be used)\n\
2018   -nostdinc++               Do not search system include directories for C++\n\
2019   -o <file>                 Put output into <file>\n\
2020 "), stdout);
2021   fputs (_("\
2022   -trigraphs                Support ISO C trigraphs\n\
2023   -std=<std name>           Specify the conformance standard; one of:\n\
2024                             gnu89, gnu99, c89, c99, iso9899:1990,\n\
2025                             iso9899:199409, iso9899:1999, c++98\n\
2026   -w                        Inhibit warning messages\n\
2027   -W[no-]trigraphs          Warn if trigraphs are encountered\n\
2028   -W[no-]comment{s}         Warn if one comment starts inside another\n\
2029 "), stdout);
2030   fputs (_("\
2031   -W[no-]traditional        Warn about features not present in traditional C\n\
2032   -W[no-]undef              Warn if an undefined macro is used by #if\n\
2033   -W[no-]import             Warn about the use of the #import directive\n\
2034 "), stdout);
2035   fputs (_("\
2036   -W[no-]error              Treat all warnings as errors\n\
2037   -W[no-]system-headers     Do not suppress warnings from system headers\n\
2038   -W[no-]all                Enable most preprocessor warnings\n\
2039 "), stdout);
2040   fputs (_("\
2041   -M                        Generate make dependencies\n\
2042   -MM                       As -M, but ignore system header files\n\
2043   -MD                       Generate make dependencies and compile\n\
2044   -MMD                      As -MD, but ignore system header files\n\
2045   -MF <file>                Write dependency output to the given file\n\
2046   -MG                       Treat missing header file as generated files\n\
2047 "), stdout);
2048   fputs (_("\
2049   -MP                       Generate phony targets for all headers\n\
2050   -MQ <target>              Add a MAKE-quoted target\n\
2051   -MT <target>              Add an unquoted target\n\
2052 "), stdout);
2053   fputs (_("\
2054   -D<macro>                 Define a <macro> with string '1' as its value\n\
2055   -D<macro>=<val>           Define a <macro> with <val> as its value\n\
2056   -A<question>=<answer>     Assert the <answer> to <question>\n\
2057   -A-<question>=<answer>    Disable the <answer> to <question>\n\
2058   -U<macro>                 Undefine <macro> \n\
2059   -v                        Display the version number\n\
2060 "), stdout);
2061   fputs (_("\
2062   -H                        Print the name of header files as they are used\n\
2063   -C                        Do not discard comments\n\
2064   -dM                       Display a list of macro definitions active at end\n\
2065   -dD                       Preserve macro definitions in output\n\
2066   -dN                       As -dD except that only the names are preserved\n\
2067   -dI                       Include #include directives in the output\n\
2068 "), stdout);
2069   fputs (_("\
2070   -f[no-]preprocessed       Treat the input file as already preprocessed\n\
2071   -ftabstop=<number>        Distance between tab stops for column reporting\n\
2072   -isysroot <dir>           Set <dir> to be the system root directory\n\
2073   -P                        Do not generate #line directives\n\
2074   -remap                    Remap file names when including files\n\
2075   --help                    Display this information\n\
2076 "), stdout);
2077 }