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