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