c-common.h (enum c_language_kind): Emphasize that clk_c is 0.
[platform/upstream/gcc.git] / gcc / c-opts.c
1 /* C/ObjC/C++ command line option handling.
2    Copyright (C) 2002 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 "tree.h"
25 #include "c-common.h"
26 #include "c-pragma.h"
27 #include "flags.h"
28 #include "toplev.h"
29 #include "langhooks.h"
30 #include "tree-inline.h"
31 #include "diagnostic.h"
32 #include "intl.h"
33
34 static cpp_options *cpp_opts;
35
36 static void missing_arg PARAMS ((size_t));
37 static size_t find_opt PARAMS ((const char *, int));
38 static void set_Wimplicit PARAMS ((int));
39 static void complain_wrong_lang PARAMS ((size_t));
40 static void write_langs PARAMS ((char *, int));
41 static void print_help PARAMS ((void));
42 static void handle_OPT_d PARAMS ((const char *));
43 static void set_std_cxx98 PARAMS ((int));
44 static void set_std_c89 PARAMS ((int, int));
45 static void set_std_c99 PARAMS ((int));
46
47 #define CL_C_ONLY       (1 << 0) /* Only C.  */
48 #define CL_OBJC_ONLY    (1 << 1) /* Only ObjC.  */
49 #define CL_CXX_ONLY     (1 << 2) /* Only C++.  */
50 #define CL_OBJCXX_ONLY  (1 << 3) /* Only ObjC++.  */
51 #define CL_JOINED       (1 << 4) /* If takes joined argument.  */
52 #define CL_SEPARATE     (1 << 5) /* If takes a separate argument.  */
53
54 #define CL_ARG          (CL_JOINED | CL_SEPARATE)
55 #define CL_C            (CL_C_ONLY | CL_OBJC_ONLY)
56 #define CL_OBJC         (CL_OBJC_ONLY | CL_OBJCXX_ONLY)
57 #define CL_CXX          (CL_CXX_ONLY | CL_OBJCXX_ONLY)
58 #define CL_ALL          (CL_C | CL_CXX)
59
60 /* This is the list of all command line options, with the leading "-"
61    removed.  It must be sorted in ASCII collating order.  All options
62    beginning with "f" or "W" are implicitly assumed to take a "no-"
63    form; this form should not be listed.  The variable "on" is true if
64    the positive form is given, otherwise it is false.  If you don't
65    want to allow a "no-" form, your handler should reject "on" being
66    false by returning zero.  See, for example, the handling of
67    -ftabstop=.
68
69    If the user gives an option to a front end that doesn't support it,
70    an error is output, mentioning which front ends the option is valid
71    for.  If you don't want this, you must accept it for all front
72    ends, and test for the front end in the option handler.  See, for
73    example, the handling of -Wno-strict-prototypes for C++.
74
75    If you request an argument with CL_JOINED, CL_SEPARATE or their
76    combination CL_ARG, it is stored in the variable "arg", which is
77    guaranteed to be non-NULL and to not be an empty string.  It points
78    to the argument either within the argv[] vector or within one of
79    that vector's strings, and so the text is permanent and copies need
80    not be made.  Be sure to add an error message in missing_arg() if
81    the default is not appropriate.  */
82
83 #define COMMAND_LINE_OPTIONS                                                 \
84   OPT("-help",                  CL_ALL,   OPT__help)                         \
85   OPT("C",                      CL_ALL,   OPT_C)                             \
86   OPT("CC",                     CL_ALL,   OPT_CC)                            \
87   OPT("E",                      CL_ALL,   OPT_E)                             \
88   OPT("H",                      CL_ALL,   OPT_H)                             \
89   OPT("P",                      CL_ALL,   OPT_P)                             \
90   OPT("Wall",                   CL_ALL,   OPT_Wall)                          \
91   OPT("Wbad-function-cast",     CL_C,     OPT_Wbad_function_cast)            \
92   OPT("Wcast-qual",             CL_ALL,   OPT_Wcast_qual)                    \
93   OPT("Wchar-subscripts",       CL_ALL,   OPT_Wchar_subscripts)              \
94   OPT("Wcomment",               CL_ALL,   OPT_Wcomment)                      \
95   OPT("Wcomments",              CL_ALL,   OPT_Wcomments)                     \
96   OPT("Wconversion",            CL_ALL,   OPT_Wconversion)                   \
97   OPT("Wctor-dtor-privacy",     CL_CXX,   OPT_Wctor_dtor_privacy)            \
98   OPT("Wdeprecated",            CL_CXX,   OPT_Wdeprecated)                   \
99   OPT("Wdiv-by-zero",           CL_C,     OPT_Wdiv_by_zero)                  \
100   OPT("Weffc++",                CL_CXX,   OPT_Weffcxx)                       \
101   OPT("Wendif-labels",          CL_ALL,   OPT_Wendif_labels)                 \
102   OPT("Werror",                 CL_ALL,   OPT_Werror)                        \
103   OPT("Werror-implicit-function-declaration",                                \
104                                 CL_C,     OPT_Werror_implicit_function_decl) \
105   OPT("Wfloat-equal",           CL_ALL,   OPT_Wfloat_equal)                  \
106   OPT("Wformat",                CL_ALL,   OPT_Wformat)                       \
107   OPT("Wformat-extra-args",     CL_ALL,   OPT_Wformat_extra_args)            \
108   OPT("Wformat-nonliteral",     CL_ALL,   OPT_Wformat_nonliteral)            \
109   OPT("Wformat-security",       CL_ALL,   OPT_Wformat_security)              \
110   OPT("Wformat-y2k",            CL_ALL,   OPT_Wformat_y2k)                   \
111   OPT("Wformat-zero-length",    CL_C,     OPT_Wformat_zero_length)           \
112   OPT("Wformat=",               CL_ALL | CL_JOINED, OPT_Wformat_eq)          \
113   OPT("Wimplicit",              CL_CXX,   OPT_Wimplicit)                     \
114   OPT("Wimplicit-function-declaration", CL_C, OPT_Wimplicit_function_decl)   \
115   OPT("Wimplicit-int",          CL_C,     OPT_Wimplicit_int)                 \
116   OPT("Wimport",                CL_ALL,   OPT_Wimport)                       \
117   OPT("Wlong-long",             CL_ALL,   OPT_Wlong_long)                    \
118   OPT("Wmain",                  CL_C,     OPT_Wmain)                         \
119   OPT("Wmissing-braces",        CL_ALL,   OPT_Wmissing_braces)               \
120   OPT("Wmissing-declarations",  CL_C,     OPT_Wmissing_declarations)         \
121   OPT("Wmissing-format-attribute",CL_ALL, OPT_Wmissing_format_attribute)     \
122   OPT("Wmissing-prototypes",    CL_ALL,   OPT_Wmissing_prototypes)           \
123   OPT("Wmultichar",             CL_ALL,   OPT_Wmultichar)                    \
124   OPT("Wnested-externs",        CL_C,     OPT_Wnested_externs)               \
125   OPT("Wnon-template-friend",   CL_CXX,   OPT_Wnon_template_friend)          \
126   OPT("Wnon-virtual-dtor",      CL_CXX,   OPT_Wnon_virtual_dtor)             \
127   OPT("Wnonnull",               CL_C,     OPT_Wnonnull)                      \
128   OPT("Wold-style-cast",        CL_CXX,   OPT_Wold_style_cast)               \
129   OPT("Woverloaded-virtual",    CL_CXX,   OPT_Woverloaded_virtual)           \
130   OPT("Wparentheses",           CL_ALL,   OPT_Wparentheses)                  \
131   OPT("Wpmf-conversions",       CL_CXX,   OPT_Wpmf_conversions)              \
132   OPT("Wpointer-arith",         CL_ALL,   OPT_Wpointer_arith)                \
133   OPT("Wprotocol",              CL_OBJC,  OPT_Wprotocol)                     \
134   OPT("Wredundant-decls",       CL_ALL,   OPT_Wredundant_decls)              \
135   OPT("Wreorder",               CL_CXX,   OPT_Wreorder)                      \
136   OPT("Wreturn-type",           CL_ALL,   OPT_Wreturn_type)                  \
137   OPT("Wselector",              CL_OBJC,  OPT_Wselector)                     \
138   OPT("Wsequence-point",        CL_C,     OPT_Wsequence_point)               \
139   OPT("Wsign-compare",          CL_ALL,   OPT_Wsign_compare)                 \
140   OPT("Wsign-promo",            CL_CXX,   OPT_Wsign_promo)                   \
141   OPT("Wstrict-prototypes",     CL_ALL,   OPT_Wstrict_prototypes)            \
142   OPT("Wsynth",                 CL_CXX,   OPT_Wsynth)                        \
143   OPT("Wsystem-headers",        CL_ALL,   OPT_Wsystem_headers)               \
144   OPT("Wtraditional",           CL_C,     OPT_Wtraditional)                  \
145   OPT("Wtrigraphs",             CL_ALL,   OPT_Wtrigraphs)                    \
146   OPT("Wundef",                 CL_ALL,   OPT_Wundef)                        \
147   OPT("Wunknown-pragmas",       CL_ALL,   OPT_Wunknown_pragmas)              \
148   OPT("Wunused-macros",         CL_ALL,   OPT_Wunused_macros)                \
149   OPT("Wwrite-strings",         CL_ALL,   OPT_Wwrite_strings)                \
150   OPT("ansi",                   CL_ALL,   OPT_ansi)                          \
151   OPT("d",                      CL_ALL | CL_JOINED, OPT_d)                   \
152   OPT("faccess-control",        CL_CXX,   OPT_faccess_control)               \
153   OPT("fall-virtual",           CL_CXX,   OPT_fall_virtual)                  \
154   OPT("falt-external-templates",CL_CXX,   OPT_falt_external_templates)       \
155   OPT("fasm",                   CL_ALL,   OPT_fasm)                          \
156   OPT("fbuiltin",               CL_ALL,   OPT_fbuiltin)                      \
157   OPT("fbuiltin-",              CL_ALL | CL_JOINED, OPT_fbuiltin_)           \
158   OPT("fcheck-new",             CL_CXX,   OPT_fcheck_new)                    \
159   OPT("fcond-mismatch",         CL_ALL,   OPT_fcond_mismatch)                \
160   OPT("fconserve-space",        CL_CXX,   OPT_fconserve_space)               \
161   OPT("fconst-strings",         CL_CXX,   OPT_fconst_strings)                \
162   OPT("fconstant-string-class=", CL_OBJC | CL_JOINED,                        \
163                                           OPT_fconstant_string_class)        \
164   OPT("fdefault-inline",        CL_CXX,   OPT_fdefault_inline)               \
165   OPT("fdollars-in-identifiers",CL_ALL,   OPT_fdollars_in_identifiers)       \
166   OPT("fdump-",                 CL_ALL | CL_JOINED, OPT_fdump)               \
167   OPT("felide-constructors",    CL_CXX,   OPT_felide_constructors)           \
168   OPT("fenforce-eh-specs",      CL_CXX,   OPT_fenforce_eh_specs)             \
169   OPT("fenum-int-equiv",        CL_CXX,   OPT_fenum_int_equiv)               \
170   OPT("fexternal-templates",    CL_CXX,   OPT_fexternal_templates)           \
171   OPT("ffor-scope",             CL_CXX,   OPT_ffor_scope)                    \
172   OPT("ffreestanding",          CL_C,     OPT_ffreestanding)                 \
173   OPT("fgnu-keywords",          CL_CXX,   OPT_fgnu_keywords)                 \
174   OPT("fgnu-runtime",           CL_OBJC,  OPT_fgnu_runtime)                  \
175   OPT("fguiding-decls",         CL_CXX,   OPT_fguiding_decls)                \
176   OPT("fhandle-exceptions",     CL_CXX,   OPT_fhandle_exceptions)            \
177   OPT("fhonor-std",             CL_CXX,   OPT_fhonor_std)                    \
178   OPT("fhosted",                CL_C,     OPT_fhosted)                       \
179   OPT("fhuge-objects",          CL_CXX,   OPT_fhuge_objects)                 \
180   OPT("fimplement-inlines",     CL_CXX,   OPT_fimplement_inlines)            \
181   OPT("fimplicit-inline-templates", CL_CXX, OPT_fimplicit_inline_templates)  \
182   OPT("fimplicit-templates",    CL_CXX,   OPT_fimplicit_templates)           \
183   OPT("flabels-ok",             CL_CXX,   OPT_flabels_ok)                    \
184   OPT("fms-extensions",         CL_ALL,   OPT_fms_extensions)                \
185   OPT("fname-mangling-version-",CL_CXX | CL_JOINED, OPT_fname_mangling)      \
186   OPT("fnew-abi",               CL_CXX,   OPT_fnew_abi)                      \
187   OPT("fnext-runtime",          CL_OBJC,  OPT_fnext_runtime)                 \
188   OPT("fnonansi-builtins",      CL_CXX,   OPT_fnonansi_builtins)             \
189   OPT("fnonnull-objects",       CL_CXX,   OPT_fnonnull_objects)              \
190   OPT("foperator-names",        CL_CXX,   OPT_foperator_names)               \
191   OPT("foptional-diags",        CL_CXX,   OPT_foptional_diags)               \
192   OPT("fpermissive",            CL_CXX,   OPT_fpermissive)                   \
193   OPT("fpreprocessed",          CL_ALL,   OPT_fpreprocessed)                 \
194   OPT("frepo",                  CL_CXX,   OPT_frepo)                         \
195   OPT("frtti",                  CL_CXX,   OPT_frtti)                         \
196   OPT("fshort-double",          CL_ALL,   OPT_fshort_double)                 \
197   OPT("fshort-enums",           CL_ALL,   OPT_fshort_enums)                  \
198   OPT("fshort-wchar",           CL_ALL,   OPT_fshort_wchar)                  \
199   OPT("fshow-column",           CL_ALL,   OPT_fshow_column)                  \
200   OPT("fsigned-bitfields",      CL_ALL,   OPT_fsigned_bitfields)             \
201   OPT("fsigned-char",           CL_ALL,   OPT_fsigned_char)                  \
202   OPT("fsquangle",              CL_CXX,   OPT_fsquangle)                     \
203   OPT("fstats",                 CL_CXX,   OPT_fstats)                        \
204   OPT("fstrict-prototype",      CL_CXX,   OPT_fstrict_prototype)             \
205   OPT("ftabstop=",              CL_ALL | CL_JOINED, OPT_ftabstop)            \
206   OPT("ftemplate-depth-",       CL_CXX | CL_JOINED, OPT_ftemplate_depth)     \
207   OPT("fthis-is-variable",      CL_CXX,   OPT_fthis_is_variable)             \
208   OPT("funsigned-bitfields",    CL_ALL,   OPT_funsigned_bitfields)           \
209   OPT("funsigned-char",         CL_ALL,   OPT_funsigned_char)                \
210   OPT("fuse-cxa-atexit",        CL_CXX,   OPT_fuse_cxa_atexit)               \
211   OPT("fvtable-gc",             CL_CXX,   OPT_fvtable_gc)                    \
212   OPT("fvtable-thunks",         CL_CXX,   OPT_fvtable_thunks)                \
213   OPT("fweak",                  CL_CXX,   OPT_fweak)                         \
214   OPT("fxref",                  CL_CXX,   OPT_fxref)                         \
215   OPT("gen-decls",              CL_OBJC,  OPT_gen_decls)                     \
216   OPT("lang-asm",               CL_C_ONLY, OPT_lang_asm)                     \
217   OPT("lang-objc",              CL_ALL,   OPT_lang_objc)                     \
218   OPT("nostdinc",               CL_ALL,   OPT_nostdinc)                      \
219   OPT("nostdinc++",             CL_ALL,   OPT_nostdincplusplus)              \
220   OPT("o",                      CL_ALL | CL_ARG, OPT_o)                      \
221   OPT("pedantic",               CL_ALL,   OPT_pedantic)                      \
222   OPT("pedantic-errors",        CL_ALL,   OPT_pedantic_errors)               \
223   OPT("print-objc-runtime-info", CL_OBJC, OPT_print_objc_runtime_info)       \
224   OPT("remap",                  CL_ALL,   OPT_remap)                         \
225   OPT("std=c++98",              CL_CXX,   OPT_std_cplusplus98)               \
226   OPT("std=c89",                CL_C,     OPT_std_c89)                       \
227   OPT("std=c99",                CL_C,     OPT_std_c99)                       \
228   OPT("std=c9x",                CL_C,     OPT_std_c9x)                       \
229   OPT("std=gnu++98",            CL_CXX,   OPT_std_gnuplusplus98)             \
230   OPT("std=gnu89",              CL_C,     OPT_std_gnu89)                     \
231   OPT("std=gnu99",              CL_C,     OPT_std_gnu99)                     \
232   OPT("std=gnu9x",              CL_C,     OPT_std_gnu9x)                     \
233   OPT("std=iso9899:1990",       CL_C,     OPT_std_iso9899_1990)              \
234   OPT("std=iso9899:199409",     CL_C,     OPT_std_iso9899_199409)            \
235   OPT("std=iso9899:1999",       CL_C,     OPT_std_iso9899_1999)              \
236   OPT("std=iso9899:199x",       CL_C,     OPT_std_iso9899_199x)              \
237   OPT("traditional-cpp",        CL_ALL,   OPT_traditional_cpp)               \
238   OPT("trigraphs",              CL_ALL,   OPT_trigraphs)                     \
239   OPT("undef",                  CL_ALL,   OPT_undef)                         \
240   OPT("v",                      CL_ALL,   OPT_v)                             \
241   OPT("w",                      CL_ALL,   OPT_w)
242
243 #define OPT(text, flags, code) code,
244 enum opt_code
245 {
246   COMMAND_LINE_OPTIONS
247   N_OPTS
248 };
249 #undef OPT
250
251 struct cl_option
252 {
253   const char *opt_text;
254   unsigned char opt_len;
255   unsigned char flags;
256   ENUM_BITFIELD (opt_code) opt_code : 2 * CHAR_BIT;
257 };
258
259 #define OPT(text, flags, code) { text, sizeof(text) - 1, flags, code },
260 #ifdef HOST_EBCDIC
261 static struct cl_option cl_options[] =
262 #else
263 static const struct cl_option cl_options[] =
264 #endif
265 {
266   COMMAND_LINE_OPTIONS
267 };
268 #undef OPT
269 #undef COMMAND_LINE_OPTIONS
270
271 #ifdef HOST_EBCDIC
272 static int opt_comp PARAMS ((const void *, const void *));
273
274 /* Run-time sorting of options array.  */
275 static int
276 opt_comp (p1, p2)
277      const void *p1, *p2;
278 {
279   return strcmp (((struct cl_option *) p1)->opt_text,
280                  ((struct cl_option *) p2)->opt_text);
281 }
282 #endif
283
284 /* Complain that switch OPT_INDEX expects an argument but none was
285    provided.  */
286 static void
287 missing_arg (opt_index)
288      size_t opt_index;
289 {
290   switch (opt_index)
291     {
292     case OPT_Wformat_eq:
293     case OPT_d:
294     case OPT_fbuiltin_:
295     case OPT_fdump:
296     case OPT_fname_mangling:
297     case OPT_ftabstop:
298     case OPT_ftemplate_depth:
299     default:
300       error ("missing argument to \"-%s\"", cl_options[opt_index].opt_text);
301       break;
302
303     case OPT_fconstant_string_class:
304       error ("no class name specified with -fconstant-string-class=");
305       break;
306
307     case OPT_o:
308       error ("missing filename after \"-%s\"", cl_options[opt_index].opt_text);
309       break;
310     }
311 }
312
313 /* Perform a binary search to find which option the command-line INPUT
314    matches.  Returns its index in the option array, and N_OPTS on
315    failure.
316
317    Complications arise since some options can be suffixed with an
318    argument, and multiple complete matches can occur, e.g. -pedantic
319    and -pedantic-errors.  Also, some options are only accepted by some
320    languages.  */
321 static size_t
322 find_opt (input, lang_flag)
323      const char *input;
324      int lang_flag;
325 {
326   size_t md, mn, mx;
327   size_t opt_len;
328   size_t wrong_lang = N_OPTS;
329   int comp;
330
331   mn = 0;
332   mx = N_OPTS;
333
334   while (mx > mn)
335     {
336       md = (mn + mx) / 2;
337
338       opt_len = cl_options[md].opt_len;
339       comp = memcmp (input, cl_options[md].opt_text, opt_len);
340
341       if (comp < 0)
342         mx = md;
343       else if (comp > 0)
344         mn = md + 1;
345       else
346         {
347           /* The switch matches.  It it an exact match?  */
348           if (input[opt_len] == '\0')
349             {
350             exact_match:
351               if (cl_options[md].flags & lang_flag)
352                 return md;
353               wrong_lang = md;
354               break;
355             }
356           else
357             {
358               mn = md + 1;
359
360               /* If the switch takes no arguments this is not a proper
361                  match, so we continue the search (e.g. input="stdc++"
362                  match was "stdc").  */
363               if (!(cl_options[md].flags & CL_JOINED))
364                 continue;
365
366               /* Is this switch valid for this front end?  */
367               if (!(cl_options[md].flags & lang_flag))
368                 {
369                   /* If subsequently we don't find a good match,
370                      report this as a bad match.  */
371                   wrong_lang = md;
372                   continue;
373                 }
374
375               /* Two scenarios remain: we have the switch's argument,
376                  or we match a longer option.  This can happen with
377                  -iwithprefix and -withprefixbefore.  The longest
378                  possible option match succeeds.
379
380                  Scan forwards, and return an exact match.  Otherwise
381                  return the longest valid option-accepting match (mx).
382                  This loops at most twice with current options.  */
383               mx = md;
384               for (md = md + 1; md < (size_t) N_OPTS; md++)
385                 {
386                   opt_len = cl_options[md].opt_len;
387                   if (memcmp (input, cl_options[md].opt_text, opt_len))
388                     break;
389                   if (input[opt_len] == '\0')
390                     goto exact_match;
391                   if (cl_options[md].flags & lang_flag
392                       && cl_options[md].flags & CL_JOINED)
393                     mx = md;
394                 }
395
396               return mx;
397             }
398         }
399     }
400
401   if (wrong_lang != N_OPTS)
402     complain_wrong_lang (wrong_lang);
403
404   return N_OPTS;
405 }
406
407 /* Common initialization before parsing options.  */
408 void
409 c_common_init_options (lang)
410      enum c_language_kind lang;
411 {
412 #ifdef HOST_EBCDIC
413   /* For non-ASCII hosts, the cl_options array needs to be sorted at
414      runtime.  */
415   qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp);
416 #endif
417
418   c_language = lang;
419   parse_in = cpp_create_reader (lang == clk_c
420                                 ? CLK_GNUC89 : CLK_GNUCXX);
421   cpp_opts = cpp_get_options (parse_in);
422
423   if (flag_objc)
424     cpp_opts->objc = 1;
425
426   flag_const_strings = (lang == clk_cplusplus);
427   warn_pointer_arith = (lang == clk_cplusplus);
428   if (lang == clk_c)
429     warn_sign_compare = -1;
430
431   /* Mark as "unspecified" (see c_common_post_options).  */
432   flag_bounds_check = -1;
433 }
434
435 /* Handle one command-line option in (argc, argv).
436    Can be called multiple times, to handle multiple sets of options.
437    Returns number of strings consumed.  */
438 int
439 c_common_decode_option (argc, argv)
440      int argc;
441      char **argv;
442 {
443   static int lang_flags[] = {CL_C_ONLY, CL_C, CL_CXX_ONLY, CL_CXX};
444   size_t opt_index;
445   const char *opt, *arg = 0;
446   char *dup = 0;
447   bool on = true;
448   int result;
449   const struct cl_option *option;
450   enum opt_code code;
451
452   opt = argv[0];
453
454   /* Interpret "-" or a non-switch as a file name.  */
455   if (opt[0] != '-' || opt[1] == '\0')
456     {
457       if (!cpp_opts->in_fname)
458         cpp_opts->in_fname = opt;
459       else if (!cpp_opts->out_fname)
460         cpp_opts->out_fname = opt;
461       else
462         {
463           error ("too many filenames given.  Type %s --help for usage",
464                  progname);
465           return argc;
466         }
467
468       return 1;
469     }
470
471   /* Drop the "no-" from negative switches.  */
472   if ((opt[1] == 'W' || opt[1] == 'f')
473       && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
474     {
475       size_t len = strlen (opt) - 3;
476
477       dup = xmalloc (len + 1);
478       dup[0] = '-';
479       dup[1] = opt[1];
480       memcpy (dup + 2, opt + 5, len - 2 + 1);
481       opt = dup;
482       on = false;
483     }
484
485   result = cpp_handle_option (parse_in, argc, argv);
486
487   /* Skip over '-'.  */
488   opt_index = find_opt (opt + 1, lang_flags[(c_language << 1) + flag_objc]);
489   if (opt_index == N_OPTS)
490     goto done;
491
492   result = 1;
493   option = &cl_options[opt_index];
494
495   /* Sort out any argument the switch takes.  */
496   if (option->flags & CL_ARG)
497     {
498       if (option->flags & CL_JOINED)
499         {
500           /* Have arg point to the original switch.  This is because
501              some code, such as disable_builtin_function, expects its
502              argument to be persistent until the program exits.  */
503           arg = argv[0] + cl_options[opt_index].opt_len + 1;
504           if (!on)
505             arg += strlen ("no-");
506         }
507
508       /* If we don't have an argument, and CL_SEPARATE, try the next
509          argument in the vector.  */
510       if (!arg || (*arg == '\0' && option->flags & CL_SEPARATE))
511         {
512           arg = argv[1];
513           result = 2;
514         }
515
516       if (!arg || *arg == '\0')
517         {
518           missing_arg (opt_index);
519           result = argc;
520           goto done;
521         }
522     }
523
524   switch (code = option->opt_code)
525     {
526     case N_OPTS: /* Shut GCC up.  */
527       break;
528
529     case OPT__help:
530       print_help ();
531       break;
532
533     case OPT_C:
534       cpp_opts->discard_comments = 0;
535       break;
536
537     case OPT_CC:
538       cpp_opts->discard_comments = 0;
539       cpp_opts->discard_comments_in_macro_exp = 0;
540       break;
541
542     case OPT_E:
543       flag_preprocess_only = 1;
544       break;
545
546     case OPT_H:
547       cpp_opts->print_include_names = 1;
548       break;
549
550     case OPT_P:
551       cpp_opts->no_line_commands = 1;
552       break;
553
554     case OPT_Wall:
555       set_Wunused (on);
556       set_Wformat (on);
557       set_Wimplicit (on);
558       warn_char_subscripts = on;
559       warn_missing_braces = on;
560       warn_multichar = on;      /* Was C++ only.  */
561       warn_parentheses = on;
562       warn_return_type = on;
563       warn_sequence_point = on; /* Was C only.  */
564       warn_sign_compare = on;   /* Was C++ only.  */
565       warn_switch = on;
566
567       /* Only warn about unknown pragmas that are not in system
568          headers.  */                                        
569       warn_unknown_pragmas = on;
570
571       /* We save the value of warn_uninitialized, since if they put
572          -Wuninitialized on the command line, we need to generate a
573          warning about not using it without also specifying -O.  */
574       if (warn_uninitialized != 1)
575         warn_uninitialized = (on ? 2 : 0);
576
577       if (c_language == clk_c)
578         /* We set this to 2 here, but 1 in -Wmain, so -ffreestanding
579            can turn it off only if it's not explicit.  */
580         warn_main = on * 2;
581       else
582         {
583           /* C++-specific warnings.  */
584           warn_ctor_dtor_privacy = on;
585           warn_nonvdtor = on;
586           warn_reorder = on;
587           warn_nontemplate_friend = on;
588         }
589
590       cpp_opts->warn_trigraphs = on;
591       cpp_opts->warn_comments = on;
592       cpp_opts->warn_num_sign_change = on;
593       break;
594
595     case OPT_Wbad_function_cast:
596       warn_bad_function_cast = on;
597       break;
598
599     case OPT_Wcast_qual:
600       warn_cast_qual = on;
601       break;
602
603     case OPT_Wchar_subscripts:
604       warn_char_subscripts = on;
605       break;
606
607     case OPT_Wcomment:
608     case OPT_Wcomments:
609       cpp_opts->warn_comments = on;
610       break;
611
612     case OPT_Wconversion:
613       warn_conversion = on;
614       break;
615
616     case OPT_Wctor_dtor_privacy:
617       warn_ctor_dtor_privacy = on;
618       break;
619
620     case OPT_Wdeprecated:
621       warn_deprecated = on;
622       break;
623
624     case OPT_Wdiv_by_zero:
625       warn_div_by_zero = on;
626       break;
627
628     case OPT_Weffcxx:
629       warn_ecpp = on;
630       break;
631
632     case OPT_Wendif_labels:
633       cpp_opts->warn_endif_labels = on;
634       break;
635
636     case OPT_Werror:
637       cpp_opts->warnings_are_errors = on;
638       break;
639
640     case OPT_Werror_implicit_function_decl:
641       if (!on)
642         result = 0;
643       else
644         mesg_implicit_function_declaration = 2;
645       break;
646
647     case OPT_Wfloat_equal:
648       warn_float_equal = on;
649       break;
650
651     case OPT_Wformat:
652       set_Wformat (on);
653       break;
654
655     case OPT_Wformat_eq:
656       set_Wformat (atoi (arg));
657       break;
658
659     case OPT_Wformat_extra_args:
660       warn_format_extra_args = on;
661       break;
662
663     case OPT_Wformat_nonliteral:
664       warn_format_nonliteral = on;
665       break;
666
667     case OPT_Wformat_security:
668       warn_format_security = on;
669       break;
670
671     case OPT_Wformat_y2k:
672       warn_format_y2k = on;
673       break;
674
675     case OPT_Wformat_zero_length:
676       warn_format_zero_length = on;
677       break;
678
679     case OPT_Wimplicit:
680       set_Wimplicit (on);
681       break;
682
683     case OPT_Wimplicit_function_decl:
684       mesg_implicit_function_declaration = on;
685       break;
686
687     case OPT_Wimplicit_int:
688       warn_implicit_int = on;
689       break;
690
691     case OPT_Wimport:
692       cpp_opts->warn_import = on;
693       break;
694
695     case OPT_Wlong_long:
696       warn_long_long = on;
697       break;
698
699     case OPT_Wmain:
700       if (on)
701         warn_main = 1;
702       else
703         warn_main = -1;
704       break;
705
706     case OPT_Wmissing_braces:
707       warn_missing_braces = on;
708       break;
709
710     case OPT_Wmissing_declarations:
711       warn_missing_declarations = on;
712       break;
713
714     case OPT_Wmissing_format_attribute:
715       warn_missing_format_attribute = on;
716       break;
717
718     case OPT_Wmissing_prototypes:
719       warn_missing_prototypes = on;
720       break;
721
722     case OPT_Wmultichar:
723       warn_multichar = on;
724       break;
725
726     case OPT_Wnested_externs:
727       warn_nested_externs = on;
728       break;
729
730     case OPT_Wnon_template_friend:
731       warn_nontemplate_friend = on;
732       break;
733
734     case OPT_Wnon_virtual_dtor:
735       warn_nonvdtor = on;
736       break;
737
738     case OPT_Wnonnull:
739       warn_nonnull = on;
740       break;
741
742     case OPT_Wold_style_cast:
743       warn_old_style_cast = on;
744       break;
745
746     case OPT_Woverloaded_virtual:
747       warn_overloaded_virtual = on;
748       break;
749
750     case OPT_Wparentheses:
751       warn_parentheses = on;
752       break;
753
754     case OPT_Wpmf_conversions:
755       warn_pmf2ptr = on;
756       break;
757
758     case OPT_Wpointer_arith:
759       warn_pointer_arith = on;
760       break;
761
762     case OPT_Wprotocol:
763       warn_protocol = on;
764       break;
765
766     case OPT_Wselector:
767       warn_selector = on;
768       break;
769
770     case OPT_Wredundant_decls:
771       warn_redundant_decls = on;
772       break;
773
774     case OPT_Wreorder:
775       warn_reorder = on;
776       break;
777
778     case OPT_Wreturn_type:
779       warn_return_type = on;
780       break;
781
782     case OPT_Wsequence_point:
783       warn_sequence_point = on;
784       break;
785
786     case OPT_Wsign_compare:
787       warn_sign_compare = on;
788       break;
789
790     case OPT_Wsign_promo:
791       warn_sign_promo = on;
792       break;
793
794     case OPT_Wstrict_prototypes:
795       if (!on && c_language == clk_cplusplus)
796         warning ("-Wno-strict-prototypes is not supported in C++");
797       else
798         warn_strict_prototypes = on;
799       break;
800
801     case OPT_Wsynth:
802       warn_synth = on;
803       break;
804
805     case OPT_Wsystem_headers:
806       cpp_opts->warn_system_headers = on;
807       break;
808
809     case OPT_Wtraditional:
810       warn_traditional = on;
811       cpp_opts->warn_traditional = on;
812       break;
813
814     case OPT_Wtrigraphs:
815       cpp_opts->warn_trigraphs = on;
816       break;
817
818     case OPT_Wundef:
819       cpp_opts->warn_undef = on;
820       break;
821
822     case OPT_Wunknown_pragmas:
823       /* Set to greater than 1, so that even unknown pragmas in
824          system headers will be warned about.  */  
825       warn_unknown_pragmas = on * 2;
826       break;
827
828     case OPT_Wunused_macros:
829       cpp_opts->warn_unused_macros = on;
830       break;
831
832     case OPT_Wwrite_strings:
833       if (c_language == clk_c)
834         flag_const_strings = on;
835       else
836         warn_write_strings = on;
837       break;
838       
839     case OPT_ansi:
840       if (c_language == clk_c)
841         set_std_c89 (false, true);
842       else
843         set_std_cxx98 (true);
844       break;
845
846     case OPT_d:
847       handle_OPT_d (arg);
848       break;
849
850     case OPT_fcond_mismatch:
851       if (c_language == clk_c)
852         {
853           flag_cond_mismatch = on;
854           break;
855         }
856       /* Fall through.  */
857
858     case OPT_fall_virtual:
859     case OPT_fenum_int_equiv:
860     case OPT_fguiding_decls:
861     case OPT_fhonor_std:
862     case OPT_fhuge_objects:
863     case OPT_flabels_ok:
864     case OPT_fname_mangling:
865     case OPT_fnew_abi:
866     case OPT_fnonnull_objects:
867     case OPT_fsquangle:
868     case OPT_fstrict_prototype:
869     case OPT_fthis_is_variable:
870     case OPT_fvtable_thunks:
871     case OPT_fxref:
872       warning ("switch \"%s\" is no longer supported", argv[0]);
873       break;
874
875     case OPT_faccess_control:
876       flag_access_control = on;
877       break;
878
879     case OPT_falt_external_templates:
880       flag_alt_external_templates = on;
881       if (on)
882         flag_external_templates = true;
883     cp_deprecated:
884       warning ("switch \"%s\" is deprecated, please see documentation for details", argv[0]);
885       break;
886
887     case OPT_fasm:
888       flag_no_asm = !on;
889       break;
890
891     case OPT_fbuiltin:
892       flag_no_builtin = !on;
893       break;
894
895     case OPT_fbuiltin_:
896       if (on)
897         result = 0;
898       else
899         disable_builtin_function (arg);
900       break;
901
902     case OPT_fdollars_in_identifiers:
903       dollars_in_ident = on;
904       break;
905
906     case OPT_fdump:
907       if (!on || !dump_switch_p (argv[0] + strlen ("-f")))
908         result = 0;
909       break;
910
911     case OPT_ffreestanding:
912       on = !on;
913       /* Fall through...  */
914     case OPT_fhosted:
915       flag_hosted = on;
916       flag_no_builtin = !on;
917       /* warn_main will be 2 if set by -Wall, 1 if set by -Wmain */
918       if (!on && warn_main == 2)
919         warn_main = 0;
920       break;
921
922     case OPT_fshort_double:
923       flag_short_double = on;
924       break;
925
926     case OPT_fshort_enums:
927       flag_short_enums = on;
928       break;
929
930     case OPT_fshort_wchar:
931       flag_short_wchar = on;
932       break;
933
934     case OPT_fsigned_bitfields:
935       flag_signed_bitfields = on;
936       explicit_flag_signed_bitfields = 1;
937       break;
938
939     case OPT_fsigned_char:
940       flag_signed_char = on;
941       break;
942
943     case OPT_funsigned_bitfields:
944       flag_signed_bitfields = !on;
945       explicit_flag_signed_bitfields = 1;
946       break;
947
948     case OPT_funsigned_char:
949       flag_signed_char = !on;
950       break;
951
952     case OPT_fcheck_new:
953       flag_check_new = on;
954       break;
955
956     case OPT_fconserve_space:
957       flag_conserve_space = on;
958       break;
959
960     case OPT_fconst_strings:
961       flag_const_strings = on;
962       break;
963
964     case OPT_fconstant_string_class:
965       constant_string_class_name = arg;
966       break;
967
968     case OPT_fdefault_inline:
969       flag_default_inline = on;
970       break;
971
972     case OPT_felide_constructors:
973       flag_elide_constructors = on;
974       break;
975
976     case OPT_fenforce_eh_specs:
977       flag_enforce_eh_specs = on;
978       break;
979
980     case OPT_fexternal_templates:
981       flag_external_templates = on;
982       goto cp_deprecated;
983
984     case OPT_ffor_scope:
985       flag_new_for_scope = on;
986       break;
987
988     case OPT_fgnu_keywords:
989       flag_no_gnu_keywords = !on;
990       break;
991
992     case OPT_fgnu_runtime:
993       flag_next_runtime = !on;
994       break;
995
996     case OPT_fhandle_exceptions:
997       warning ("-fhandle-exceptions has been renamed to -fexceptions (and is now on by default)");
998       flag_exceptions = on;
999       break;
1000
1001     case OPT_fimplement_inlines:
1002       flag_implement_inlines = on;
1003       break;
1004
1005     case OPT_fimplicit_inline_templates:
1006       flag_implicit_inline_templates = on;
1007       break;
1008
1009     case OPT_fimplicit_templates:
1010       flag_implicit_templates = on;
1011       break;
1012
1013     case OPT_fms_extensions:
1014       flag_ms_extensions = on;
1015       break;
1016
1017     case OPT_fnext_runtime:
1018       flag_next_runtime = on;
1019       break;
1020
1021     case OPT_fnonansi_builtins:
1022       flag_no_nonansi_builtin = !on;
1023       break;
1024
1025     case OPT_foperator_names:
1026       cpp_opts->operator_names = on;
1027       break;
1028
1029     case OPT_foptional_diags:
1030       flag_optional_diags = on;
1031       break;
1032
1033     case OPT_fpermissive:
1034       flag_permissive = on;
1035       break;
1036
1037     case OPT_fpreprocessed:
1038       cpp_opts->preprocessed = on;
1039       break;
1040
1041     case OPT_frepo:
1042       flag_use_repository = on;
1043       if (on)
1044         flag_implicit_templates = 0;
1045       break;
1046
1047     case OPT_frtti:
1048       flag_rtti = on;
1049       break;
1050
1051     case OPT_fshow_column:
1052       cpp_opts->show_column = on;
1053       break;
1054
1055     case OPT_fstats:
1056       flag_detailed_statistics = on;
1057       break;
1058
1059     case OPT_ftabstop:
1060       /* Don't recognise -fno-tabstop=.  */
1061       if (!on)
1062         return 0;
1063
1064       /* It is documented that we silently ignore silly values.  */
1065         {
1066           char *endptr;
1067           long tabstop = strtol (arg, &endptr, 10);
1068           if (*endptr == '\0' && tabstop >= 1 && tabstop <= 100)
1069             cpp_opts->tabstop = tabstop;
1070         }
1071       break;
1072
1073     case OPT_ftemplate_depth:
1074       max_tinst_depth = read_integral_parameter (arg, argv[0], 0);
1075       break;
1076
1077     case OPT_fvtable_gc:
1078       flag_vtable_gc = on;
1079       break;
1080
1081     case OPT_fuse_cxa_atexit:
1082       flag_use_cxa_atexit = on;
1083       break;
1084
1085     case OPT_fweak:
1086       flag_weak = on;
1087       break;
1088
1089     case OPT_gen_decls:
1090       flag_gen_declaration = 1;
1091       break;
1092
1093     case OPT_lang_asm:
1094       cpp_set_lang (parse_in, CLK_ASM);
1095       break;
1096
1097     case OPT_lang_objc:
1098       cpp_opts->objc = 1;
1099       break;
1100
1101     case OPT_nostdinc:
1102       /* No default include directories.  You must specify all
1103          include-file directories with -I.  */
1104       cpp_opts->no_standard_includes = 1;
1105       break;
1106
1107     case OPT_nostdincplusplus:
1108       /* No default C++-specific include directories.  */
1109       cpp_opts->no_standard_cplusplus_includes = 1;
1110       break;
1111
1112     case OPT_o:
1113       if (!cpp_opts->out_fname)
1114         cpp_opts->out_fname = arg;
1115       else
1116         {
1117           error ("output filename specified twice");
1118           result = argc;
1119         }
1120       break;
1121
1122       /* We need to handle the -pedantic switches here, rather than in
1123          c_common_post_options, so that a subsequent -Wno-endif-labels
1124          is not overridden.  */
1125     case OPT_pedantic_errors:
1126       cpp_opts->pedantic_errors = 1;
1127       /* fall through */
1128     case OPT_pedantic:
1129       cpp_opts->pedantic = 1;
1130       cpp_opts->warn_endif_labels = 1;
1131       break;
1132
1133     case OPT_print_objc_runtime_info:
1134       print_struct_values = 1;
1135       break;
1136
1137     case OPT_remap:
1138       cpp_opts->remap = 1;
1139       break;
1140
1141     case OPT_std_cplusplus98:
1142     case OPT_std_gnuplusplus98:
1143       set_std_cxx98 (code == OPT_std_cplusplus98 /* ISO */);
1144       break;
1145
1146     case OPT_std_c89:
1147     case OPT_std_iso9899_1990:
1148     case OPT_std_iso9899_199409:
1149       set_std_c89 (code == OPT_std_iso9899_199409 /* c94 */, true /* ISO */);
1150       break;
1151
1152     case OPT_std_gnu89:
1153       set_std_c89 (false /* c94 */, false /* ISO */);
1154       break;
1155
1156     case OPT_std_c99:
1157     case OPT_std_c9x:
1158     case OPT_std_iso9899_1999:
1159     case OPT_std_iso9899_199x:
1160       set_std_c99 (true /* ISO */);
1161       break;
1162
1163     case OPT_std_gnu99:
1164     case OPT_std_gnu9x:
1165       set_std_c99 (false /* ISO */);
1166       break;
1167
1168     case OPT_trigraphs:
1169       cpp_opts->trigraphs = 1;
1170       break;
1171
1172     case OPT_traditional_cpp:
1173       cpp_opts->traditional = 1;
1174       break;
1175
1176     case OPT_undef:
1177       flag_undef = 1;
1178       break;
1179
1180     case OPT_w:
1181       cpp_opts->inhibit_warnings = 1;
1182       break;
1183
1184     case OPT_v:
1185       cpp_opts->verbose = 1;
1186       break;
1187     }
1188
1189  done:
1190   if (dup)
1191     free (dup);
1192   return result;
1193 }
1194
1195 /* Post-switch processing.  */
1196 bool
1197 c_common_post_options ()
1198 {
1199   cpp_post_options (parse_in);
1200
1201   flag_inline_trees = 1;
1202
1203   /* Use tree inlining if possible.  Function instrumentation is only
1204      done in the RTL level, so we disable tree inlining.  */
1205   if (! flag_instrument_function_entry_exit)
1206     {
1207       if (!flag_no_inline)
1208         flag_no_inline = 1;
1209       if (flag_inline_functions)
1210         {
1211           flag_inline_trees = 2;
1212           flag_inline_functions = 0;
1213         }
1214     }
1215
1216   /* If still "unspecified", make it match -fbounded-pointers.  */
1217   if (flag_bounds_check == -1)
1218     flag_bounds_check = flag_bounded_pointers;
1219
1220   /* Special format checking options don't work without -Wformat; warn if
1221      they are used.  */
1222   if (warn_format_y2k && !warn_format)
1223     warning ("-Wformat-y2k ignored without -Wformat");
1224   if (warn_format_extra_args && !warn_format)
1225     warning ("-Wformat-extra-args ignored without -Wformat");
1226   if (warn_format_zero_length && !warn_format)
1227     warning ("-Wformat-zero-length ignored without -Wformat");
1228   if (warn_format_nonliteral && !warn_format)
1229     warning ("-Wformat-nonliteral ignored without -Wformat");
1230   if (warn_format_security && !warn_format)
1231     warning ("-Wformat-security ignored without -Wformat");
1232   if (warn_missing_format_attribute && !warn_format)
1233     warning ("-Wmissing-format-attribute ignored without -Wformat");
1234
1235   /* If an error has occurred in cpplib, note it so we fail
1236      immediately.  */
1237   errorcount += cpp_errors (parse_in);
1238
1239   return flag_preprocess_only;
1240 }
1241
1242 /* Set the C 89 standard (with 1994 amendments if C94, without GNU
1243    extensions if ISO).  There is no concept of gnu94.  */
1244 static void
1245 set_std_c89 (c94, iso)
1246      int c94, iso;
1247 {
1248   cpp_set_lang (parse_in, c94 ? CLK_STDC94: iso ? CLK_STDC89: CLK_GNUC89);
1249   flag_iso = iso;
1250   flag_no_asm = iso;
1251   flag_no_gnu_keywords = iso;
1252   flag_no_nonansi_builtin = iso;
1253   flag_noniso_default_format_attributes = !iso;
1254   flag_isoc94 = c94;
1255   flag_isoc99 = 0;
1256   flag_writable_strings = 0;
1257 }
1258
1259 /* Set the C 99 standard (without GNU extensions if ISO).  */
1260 static void
1261 set_std_c99 (iso)
1262      int iso;
1263 {
1264   cpp_set_lang (parse_in, iso ? CLK_STDC99: CLK_GNUC99);
1265   flag_no_asm = iso;
1266   flag_no_nonansi_builtin = iso;
1267   flag_noniso_default_format_attributes = !iso;
1268   flag_iso = iso;
1269   flag_isoc99 = 1;
1270   flag_isoc94 = 1;
1271   flag_writable_strings = 0;
1272 }
1273
1274 /* Set the C++ 98 standard (without GNU extensions if ISO).  */
1275 static void
1276 set_std_cxx98 (iso)
1277      int iso;
1278 {
1279   cpp_set_lang (parse_in, iso ? CLK_CXX98: CLK_GNUCXX);
1280   flag_no_gnu_keywords = iso;
1281   flag_no_nonansi_builtin = iso;
1282   flag_noniso_default_format_attributes = !iso;
1283   flag_iso = iso;
1284 }
1285
1286 /* Handle setting implicit to ON.  */
1287 static void
1288 set_Wimplicit (on)
1289      int on;
1290 {
1291   warn_implicit = on;
1292   warn_implicit_int = on;
1293   if (on)
1294     {
1295       if (mesg_implicit_function_declaration != 2)
1296         mesg_implicit_function_declaration = 1;
1297     }
1298   else
1299     mesg_implicit_function_declaration = 0;
1300 }
1301
1302 /* Args to -d specify what to dump.  Silently ignore
1303    unrecognised options; they may be aimed at toplev.c.  */
1304 static void
1305 handle_OPT_d (arg)
1306      const char *arg;
1307 {
1308   char c;
1309
1310   while ((c = *arg++) != '\0')
1311     switch (c)
1312       {
1313       case 'M':
1314         cpp_opts->dump_macros = dump_only;
1315         break;
1316
1317       case 'N':
1318         cpp_opts->dump_macros = dump_names;
1319         break;
1320
1321       case 'D':
1322         cpp_opts->dump_macros = dump_definitions;
1323         break;
1324
1325       case 'I':
1326         cpp_opts->dump_includes = 1;
1327         break;
1328       }
1329 }
1330
1331 /* Write a slash-separated list of languages in FLAGS to BUF.  */
1332 static void
1333 write_langs (buf, flags)
1334      char *buf;
1335      int flags;
1336 {
1337   *buf = '\0';
1338   if (flags & CL_C_ONLY)
1339     strcat (buf, "C");
1340   if (flags & CL_OBJC_ONLY)
1341     {
1342       if (*buf)
1343         strcat (buf, "/");
1344       strcat (buf, "ObjC");
1345     }
1346   if (flags & CL_CXX_ONLY)
1347     {
1348       if (*buf)
1349         strcat (buf, "/");
1350       strcat (buf, "C++");
1351     }
1352 }
1353
1354 /* Complain that switch OPT_INDEX does not apply to this front end.  */
1355 static void
1356 complain_wrong_lang (opt_index)
1357      size_t opt_index;
1358 {
1359   char ok_langs[60], bad_langs[60];
1360   int ok_flags = cl_options[opt_index].flags;
1361
1362   write_langs (ok_langs, ok_flags);
1363   write_langs (bad_langs, ~ok_flags);
1364   warning ("\"-%s\" is valid for %s but not for %s",
1365            cl_options[opt_index].opt_text, ok_langs, bad_langs);
1366 }
1367
1368 /* Handle --help output.  */
1369 static void
1370 print_help ()
1371 {
1372   /* To keep the lines from getting too long for some compilers, limit
1373      to about 500 characters (6 lines) per chunk.  */
1374   fputs (_("\
1375 Switches:\n\
1376   -include <file>           Include the contents of <file> before other files\n\
1377   -imacros <file>           Accept definition of macros in <file>\n\
1378   -iprefix <path>           Specify <path> as a prefix for next two options\n\
1379   -iwithprefix <dir>        Add <dir> to the end of the system include path\n\
1380   -iwithprefixbefore <dir>  Add <dir> to the end of the main include path\n\
1381   -isystem <dir>            Add <dir> to the start of the system include path\n\
1382 "), stdout);
1383   fputs (_("\
1384   -idirafter <dir>          Add <dir> to the end of the system include path\n\
1385   -I <dir>                  Add <dir> to the end of the main include path\n\
1386   -I-                       Fine-grained include path control; see info docs\n\
1387   -nostdinc                 Do not search system include directories\n\
1388                              (dirs specified with -isystem will still be used)\n\
1389   -nostdinc++               Do not search system include directories for C++\n\
1390   -o <file>                 Put output into <file>\n\
1391 "), stdout);
1392   fputs (_("\
1393   -trigraphs                Support ISO C trigraphs\n\
1394   -std=<std name>           Specify the conformance standard; one of:\n\
1395                             gnu89, gnu99, c89, c99, iso9899:1990,\n\
1396                             iso9899:199409, iso9899:1999, c++98\n\
1397   -w                        Inhibit warning messages\n\
1398   -W[no-]trigraphs          Warn if trigraphs are encountered\n\
1399   -W[no-]comment{s}         Warn if one comment starts inside another\n\
1400 "), stdout);
1401   fputs (_("\
1402   -W[no-]traditional        Warn about features not present in traditional C\n\
1403   -W[no-]undef              Warn if an undefined macro is used by #if\n\
1404   -W[no-]import             Warn about the use of the #import directive\n\
1405 "), stdout);
1406   fputs (_("\
1407   -W[no-]error              Treat all warnings as errors\n\
1408   -W[no-]system-headers     Do not suppress warnings from system headers\n\
1409   -W[no-]all                Enable most preprocessor warnings\n\
1410 "), stdout);
1411   fputs (_("\
1412   -M                        Generate make dependencies\n\
1413   -MM                       As -M, but ignore system header files\n\
1414   -MD                       Generate make dependencies and compile\n\
1415   -MMD                      As -MD, but ignore system header files\n\
1416   -MF <file>                Write dependency output to the given file\n\
1417   -MG                       Treat missing header file as generated files\n\
1418 "), stdout);
1419   fputs (_("\
1420   -MP                       Generate phony targets for all headers\n\
1421   -MQ <target>              Add a MAKE-quoted target\n\
1422   -MT <target>              Add an unquoted target\n\
1423 "), stdout);
1424   fputs (_("\
1425   -D<macro>                 Define a <macro> with string '1' as its value\n\
1426   -D<macro>=<val>           Define a <macro> with <val> as its value\n\
1427   -A<question>=<answer>     Assert the <answer> to <question>\n\
1428   -A-<question>=<answer>    Disable the <answer> to <question>\n\
1429   -U<macro>                 Undefine <macro> \n\
1430   -v                        Display the version number\n\
1431 "), stdout);
1432   fputs (_("\
1433   -H                        Print the name of header files as they are used\n\
1434   -C                        Do not discard comments\n\
1435   -dM                       Display a list of macro definitions active at end\n\
1436   -dD                       Preserve macro definitions in output\n\
1437   -dN                       As -dD except that only the names are preserved\n\
1438   -dI                       Include #include directives in the output\n\
1439 "), stdout);
1440   fputs (_("\
1441   -f[no-]preprocessed       Treat the input file as already preprocessed\n\
1442   -ftabstop=<number>        Distance between tab stops for column reporting\n\
1443   -P                        Do not generate #line directives\n\
1444   -remap                    Remap file names when including files\n\
1445   --help                    Display this information\n\
1446 "), stdout);
1447 }