OSDN Git Service

* doc/tm.texi.in (HANDLE_SYSV_PRAGMA,
[pf3gnuchains/gcc-fork.git] / gcc / c-family / c-opts.c
1 /* C/ObjC/C++ command line option handling.
2    Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
3    Free Software Foundation, Inc.
4    Contributed by Neil Booth.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tree.h"
26 #include "c-common.h"
27 #include "c-pragma.h"
28 #include "flags.h"
29 #include "toplev.h"
30 #include "langhooks.h"
31 #include "diagnostic.h"
32 #include "intl.h"
33 #include "cppdefault.h"
34 #include "incpath.h"
35 #include "debug.h"              /* For debug_hooks.  */
36 #include "opts.h"
37 #include "options.h"
38 #include "mkdeps.h"
39 #include "target.h"             /* For gcc_targetcm.  */
40 #include "tm_p.h"               /* For C_COMMON_OVERRIDE_OPTIONS.  */
41
42 #ifndef DOLLARS_IN_IDENTIFIERS
43 # define DOLLARS_IN_IDENTIFIERS true
44 #endif
45
46 #ifndef TARGET_SYSTEM_ROOT
47 # define TARGET_SYSTEM_ROOT NULL
48 #endif
49
50 #ifndef TARGET_OPTF
51 #define TARGET_OPTF(ARG)
52 #endif
53
54 /* CPP's options.  */
55 cpp_options *cpp_opts;
56
57 /* Input filename.  */
58 static const char *this_input_filename;
59
60 /* Filename and stream for preprocessed output.  */
61 static const char *out_fname;
62 static FILE *out_stream;
63
64 /* Append dependencies to deps_file.  */
65 static bool deps_append;
66
67 /* If dependency switches (-MF etc.) have been given.  */
68 static bool deps_seen;
69
70 /* If -v seen.  */
71 static bool verbose;
72
73 /* Dependency output file.  */
74 static const char *deps_file;
75
76 /* The prefix given by -iprefix, if any.  */
77 static const char *iprefix;
78
79 /* The multilib directory given by -imultilib, if any.  */
80 static const char *imultilib;
81
82 /* The system root, if any.  Overridden by -isysroot.  */
83 static const char *sysroot = TARGET_SYSTEM_ROOT;
84
85 /* Zero disables all standard directories for headers.  */
86 static bool std_inc = true;
87
88 /* Zero disables the C++-specific standard directories for headers.  */
89 static bool std_cxx_inc = true;
90
91 /* If the quote chain has been split by -I-.  */
92 static bool quote_chain_split;
93
94 /* If -Wunused-macros.  */
95 static bool warn_unused_macros;
96
97 /* If -Wvariadic-macros.  */
98 static bool warn_variadic_macros = true;
99
100 /* Number of deferred options.  */
101 static size_t deferred_count;
102
103 /* Number of deferred options scanned for -include.  */
104 static size_t include_cursor;
105
106 static void handle_OPT_d (const char *);
107 static void set_std_cxx98 (int);
108 static void set_std_cxx0x (int);
109 static void set_std_c89 (int, int);
110 static void set_std_c99 (int);
111 static void set_std_c1x (int);
112 static void check_deps_environment_vars (void);
113 static void handle_deferred_opts (void);
114 static void sanitize_cpp_opts (void);
115 static void add_prefixed_path (const char *, size_t);
116 static void push_command_line_include (void);
117 static void cb_file_change (cpp_reader *, const struct line_map *);
118 static void cb_dir_change (cpp_reader *, const char *);
119 static void finish_options (void);
120
121 #ifndef STDC_0_IN_SYSTEM_HEADERS
122 #define STDC_0_IN_SYSTEM_HEADERS 0
123 #endif
124
125 /* Holds switches parsed by c_common_handle_option (), but whose
126    handling is deferred to c_common_post_options ().  */
127 static void defer_opt (enum opt_code, const char *);
128 static struct deferred_opt
129 {
130   enum opt_code code;
131   const char *arg;
132 } *deferred_opts;
133
134
135 extern const unsigned int 
136 c_family_lang_mask = (CL_C | CL_CXX | CL_ObjC | CL_ObjCXX);
137
138 /* Defer option CODE with argument ARG.  */
139 static void
140 defer_opt (enum opt_code code, const char *arg)
141 {
142   deferred_opts[deferred_count].code = code;
143   deferred_opts[deferred_count].arg = arg;
144   deferred_count++;
145 }
146
147 /* Return language mask for option parsing.  */
148 unsigned int
149 c_common_option_lang_mask (void)
150 {
151   static const unsigned int lang_flags[] = {CL_C, CL_ObjC, CL_CXX, CL_ObjCXX};
152
153   return lang_flags[c_language];
154 }
155
156 /* Common diagnostics initialization.  */
157 void
158 c_common_initialize_diagnostics (diagnostic_context *context)
159 {
160   /* This is conditionalized only because that is the way the front
161      ends used to do it.  Maybe this should be unconditional?  */
162   if (c_dialect_cxx ())
163     {
164       /* By default wrap lines at 80 characters.  Is getenv
165          ("COLUMNS") preferable?  */
166       diagnostic_line_cutoff (context) = 80;
167       /* By default, emit location information once for every
168          diagnostic message.  */
169       diagnostic_prefixing_rule (context) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
170     }
171
172   context->opt_permissive = OPT_fpermissive;
173 }
174
175 /* Whether options from all C-family languages should be accepted
176    quietly.  */
177 static bool accept_all_c_family_options = false;
178
179 /* Return whether to complain about a wrong-language option.  */
180 bool
181 c_common_complain_wrong_lang_p (const struct cl_option *option)
182 {
183   if (accept_all_c_family_options
184       && (option->flags & c_family_lang_mask))
185     return false;
186
187   return true;
188 }
189
190 /* Initialize options structure OPTS.  */
191 void
192 c_common_init_options_struct (struct gcc_options *opts)
193 {
194   opts->x_flag_exceptions = c_dialect_cxx ();
195   opts->x_warn_pointer_arith = c_dialect_cxx ();
196   opts->x_warn_write_strings = c_dialect_cxx ();
197   opts->x_flag_warn_unused_result = true;
198
199   /* By default, C99-like requirements for complex multiply and divide.  */
200   opts->x_flag_complex_method = 2;
201 }
202
203 /* Common initialization before calling option handlers.  */
204 void
205 c_common_init_options (unsigned int decoded_options_count,
206                        struct cl_decoded_option *decoded_options)
207 {
208   unsigned int i;
209   struct cpp_callbacks *cb;
210
211   parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89,
212                                 ident_hash, line_table);
213   cb = cpp_get_callbacks (parse_in);
214   cb->error = c_cpp_error;
215
216   cpp_opts = cpp_get_options (parse_in);
217   cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
218   cpp_opts->objc = c_dialect_objc ();
219
220   /* Reset to avoid warnings on internal definitions.  We set it just
221      before passing on command-line options to cpplib.  */
222   cpp_opts->warn_dollars = 0;
223
224   deferred_opts = XNEWVEC (struct deferred_opt, decoded_options_count);
225
226   if (c_language == clk_c)
227     {
228       /* If preprocessing assembly language, accept any of the C-family
229          front end options since the driver may pass them through.  */
230       for (i = 1; i < decoded_options_count; i++)
231         if (decoded_options[i].opt_index == OPT_lang_asm)
232           {
233             accept_all_c_family_options = true;
234             break;
235           }
236     }
237 }
238
239 /* Handle switch SCODE with argument ARG.  VALUE is true, unless no-
240    form of an -f or -W option was given.  Returns false if the switch was
241    invalid, true if valid.  Use HANDLERS in recursive handle_option calls.  */
242 bool
243 c_common_handle_option (size_t scode, const char *arg, int value,
244                         int kind, location_t loc,
245                         const struct cl_option_handlers *handlers)
246 {
247   const struct cl_option *option = &cl_options[scode];
248   enum opt_code code = (enum opt_code) scode;
249   bool result = true;
250
251   /* Prevent resetting the language standard to a C dialect when the driver
252      has already determined that we're looking at assembler input.  */
253   bool preprocessing_asm_p = (cpp_get_options (parse_in)->lang == CLK_ASM);
254
255   switch (code)
256     {
257     default:
258       if (cl_options[code].flags & c_family_lang_mask)
259         {
260           if ((option->flags & CL_TARGET)
261               && ! targetcm.handle_c_option (scode, arg, value))
262             result = false;
263           break;
264         }
265       result = false;
266       break;
267
268     case OPT__output_pch_:
269       pch_file = arg;
270       break;
271
272     case OPT_A:
273       defer_opt (code, arg);
274       break;
275
276     case OPT_C:
277       cpp_opts->discard_comments = 0;
278       break;
279
280     case OPT_CC:
281       cpp_opts->discard_comments = 0;
282       cpp_opts->discard_comments_in_macro_exp = 0;
283       break;
284
285     case OPT_D:
286       defer_opt (code, arg);
287       break;
288
289     case OPT_H:
290       cpp_opts->print_include_names = 1;
291       break;
292
293     case OPT_F:
294       TARGET_OPTF (xstrdup (arg));
295       break;
296
297     case OPT_I:
298       if (strcmp (arg, "-"))
299         add_path (xstrdup (arg), BRACKET, 0, true);
300       else
301         {
302           if (quote_chain_split)
303             error ("-I- specified twice");
304           quote_chain_split = true;
305           split_quote_chain ();
306           inform (input_location, "obsolete option -I- used, please use -iquote instead");
307         }
308       break;
309
310     case OPT_M:
311     case OPT_MM:
312       /* When doing dependencies with -M or -MM, suppress normal
313          preprocessed output, but still do -dM etc. as software
314          depends on this.  Preprocessed output does occur if -MD, -MMD
315          or environment var dependency generation is used.  */
316       cpp_opts->deps.style = (code == OPT_M ? DEPS_SYSTEM: DEPS_USER);
317       flag_no_output = 1;
318       break;
319
320     case OPT_MD:
321     case OPT_MMD:
322       cpp_opts->deps.style = (code == OPT_MD ? DEPS_SYSTEM: DEPS_USER);
323       cpp_opts->deps.need_preprocessor_output = true;
324       deps_file = arg;
325       break;
326
327     case OPT_MF:
328       deps_seen = true;
329       deps_file = arg;
330       break;
331
332     case OPT_MG:
333       deps_seen = true;
334       cpp_opts->deps.missing_files = true;
335       break;
336
337     case OPT_MP:
338       deps_seen = true;
339       cpp_opts->deps.phony_targets = true;
340       break;
341
342     case OPT_MQ:
343     case OPT_MT:
344       deps_seen = true;
345       defer_opt (code, arg);
346       break;
347
348     case OPT_P:
349       flag_no_line_commands = 1;
350       break;
351
352     case OPT_U:
353       defer_opt (code, arg);
354       break;
355
356     case OPT_Wall:
357       warn_unused = value;
358       set_Wformat (value);
359       handle_generated_option (&global_options, &global_options_set,
360                                OPT_Wimplicit, NULL, value,
361                                c_family_lang_mask, kind, loc,
362                                handlers, global_dc);
363       warn_char_subscripts = value;
364       warn_missing_braces = value;
365       warn_parentheses = value;
366       warn_return_type = value;
367       warn_sequence_point = value;      /* Was C only.  */
368       warn_switch = value;
369       if (warn_strict_aliasing == -1)
370         set_Wstrict_aliasing (&global_options, value);
371       warn_address = value;
372       if (warn_strict_overflow == -1)
373         warn_strict_overflow = value;
374       warn_array_bounds = value;
375       warn_volatile_register_var = value;
376
377       /* Only warn about unknown pragmas that are not in system
378          headers.  */
379       warn_unknown_pragmas = value;
380
381       warn_uninitialized = value;
382
383       if (!c_dialect_cxx ())
384         {
385           /* We set this to 2 here, but 1 in -Wmain, so -ffreestanding
386              can turn it off only if it's not explicit.  */
387           if (warn_main == -1)
388             warn_main = (value ? 2 : 0);
389
390           /* In C, -Wall turns on -Wenum-compare, which we do here.
391              In C++ it is on by default, which is done in
392              c_common_post_options.  */
393           if (warn_enum_compare == -1)
394             warn_enum_compare = value;
395         }
396       else
397         {
398           /* C++-specific warnings.  */
399           warn_sign_compare = value;
400           warn_reorder = value;
401           warn_cxx0x_compat = value;
402         }
403
404       cpp_opts->warn_trigraphs = value;
405       cpp_opts->warn_comments = value;
406       cpp_opts->warn_num_sign_change = value;
407
408       if (warn_pointer_sign == -1)
409         warn_pointer_sign = value;
410       break;
411
412     case OPT_Wbuiltin_macro_redefined:
413       cpp_opts->warn_builtin_macro_redefined = value;
414       break;
415
416     case OPT_Wcomment:
417       cpp_opts->warn_comments = value;
418       break;
419
420     case OPT_Wc___compat:
421       /* Because -Wenum-compare is the default in C++, -Wc++-compat
422          implies -Wenum-compare.  */
423       if (warn_enum_compare == -1 && value)
424         warn_enum_compare = value;
425       /* Because C++ always warns about a goto which misses an
426          initialization, -Wc++-compat turns on -Wjump-misses-init.  */
427       if (warn_jump_misses_init == -1 && value)
428         warn_jump_misses_init = value;
429       cpp_opts->warn_cxx_operator_names = value;
430       break;
431
432     case OPT_Wdeprecated:
433       cpp_opts->cpp_warn_deprecated = value;
434       break;
435
436     case OPT_Wendif_labels:
437       cpp_opts->warn_endif_labels = value;
438       break;
439
440     case OPT_Werror:
441       global_dc->warning_as_error_requested = value;
442       break;
443
444     case OPT_Wformat:
445       set_Wformat (value);
446       break;
447
448     case OPT_Wformat_:
449       set_Wformat (atoi (arg));
450       break;
451
452     case OPT_Wimplicit:
453       gcc_assert (value == 0 || value == 1);
454       if (warn_implicit_int == -1)
455         handle_generated_option (&global_options, &global_options_set,
456                                  OPT_Wimplicit_int, NULL, value,
457                                  c_family_lang_mask, kind, loc, handlers,
458                                  global_dc);
459       if (warn_implicit_function_declaration == -1)
460         handle_generated_option (&global_options, &global_options_set,
461                                  OPT_Wimplicit_function_declaration, NULL,
462                                  value, c_family_lang_mask, kind, loc,
463                                  handlers, global_dc);
464       break;
465
466     case OPT_Winvalid_pch:
467       cpp_opts->warn_invalid_pch = value;
468       break;
469
470     case OPT_Wlong_long:
471       cpp_opts->cpp_warn_long_long = value;
472       break;
473
474     case OPT_Wmissing_include_dirs:
475       cpp_opts->warn_missing_include_dirs = value;
476       break;
477
478     case OPT_Wmultichar:
479       cpp_opts->warn_multichar = value;
480       break;
481
482     case OPT_Wnormalized_:
483       if (kind == DK_ERROR)
484         {
485           gcc_assert (!arg);
486           inform (input_location, "-Werror=normalized=: set -Wnormalized=nfc");
487           cpp_opts->warn_normalize = normalized_C;
488         }
489       else
490         {
491           if (!value || (arg && strcasecmp (arg, "none") == 0))
492             cpp_opts->warn_normalize = normalized_none;
493           else if (!arg || strcasecmp (arg, "nfkc") == 0)
494             cpp_opts->warn_normalize = normalized_KC;
495           else if (strcasecmp (arg, "id") == 0)
496             cpp_opts->warn_normalize = normalized_identifier_C;
497           else if (strcasecmp (arg, "nfc") == 0)
498             cpp_opts->warn_normalize = normalized_C;
499           else
500             error ("argument %qs to %<-Wnormalized%> not recognized", arg);
501           break;
502         }
503
504     case OPT_Wreturn_type:
505       warn_return_type = value;
506       break;
507
508     case OPT_Wtraditional:
509       cpp_opts->cpp_warn_traditional = value;
510       break;
511
512     case OPT_Wtrigraphs:
513       cpp_opts->warn_trigraphs = value;
514       break;
515
516     case OPT_Wundef:
517       cpp_opts->warn_undef = value;
518       break;
519
520     case OPT_Wunknown_pragmas:
521       /* Set to greater than 1, so that even unknown pragmas in
522          system headers will be warned about.  */
523       warn_unknown_pragmas = value * 2;
524       break;
525
526     case OPT_Wunused_macros:
527       warn_unused_macros = value;
528       break;
529
530     case OPT_Wvariadic_macros:
531       warn_variadic_macros = value;
532       break;
533
534     case OPT_Wwrite_strings:
535       warn_write_strings = value;
536       break;
537
538     case OPT_Weffc__:
539       warn_ecpp = value;
540       if (value)
541         warn_nonvdtor = true;
542       break;
543
544     case OPT_ansi:
545       if (!c_dialect_cxx ())
546         set_std_c89 (false, true);
547       else
548         set_std_cxx98 (true);
549       break;
550
551     case OPT_d:
552       handle_OPT_d (arg);
553       break;
554
555     case OPT_fcond_mismatch:
556       if (!c_dialect_cxx ())
557         {
558           flag_cond_mismatch = value;
559           break;
560         }
561       warning (0, "switch %qs is no longer supported", option->opt_text);
562       break;
563
564     case OPT_fbuiltin_:
565       if (value)
566         result = false;
567       else
568         disable_builtin_function (arg);
569       break;
570
571     case OPT_fdirectives_only:
572       cpp_opts->directives_only = value;
573       break;
574
575     case OPT_fdollars_in_identifiers:
576       cpp_opts->dollars_in_ident = value;
577       break;
578
579     case OPT_ffreestanding:
580       value = !value;
581       /* Fall through....  */
582     case OPT_fhosted:
583       flag_hosted = value;
584       flag_no_builtin = !value;
585       break;
586
587     case OPT_fconstant_string_class_:
588       constant_string_class_name = arg;
589       break;
590
591     case OPT_fextended_identifiers:
592       cpp_opts->extended_identifiers = value;
593       break;
594
595     case OPT_fgnu_runtime:
596       flag_next_runtime = !value;
597       break;
598
599     case OPT_fnext_runtime:
600       flag_next_runtime = value;
601       break;
602
603     case OPT_foperator_names:
604       cpp_opts->operator_names = value;
605       break;
606
607     case OPT_fpch_deps:
608       cpp_opts->restore_pch_deps = value;
609       break;
610
611     case OPT_fpch_preprocess:
612       flag_pch_preprocess = value;
613       break;
614
615     case OPT_fpermissive:
616       flag_permissive = value;
617       global_dc->permissive = value;
618       break;
619
620     case OPT_fpreprocessed:
621       cpp_opts->preprocessed = value;
622       break;
623
624     case OPT_frepo:
625       flag_use_repository = value;
626       if (value)
627         flag_implicit_templates = 0;
628       break;
629
630     case OPT_ftabstop_:
631       /* It is documented that we silently ignore silly values.  */
632       if (value >= 1 && value <= 100)
633         cpp_opts->tabstop = value;
634       break;
635
636     case OPT_fexec_charset_:
637       cpp_opts->narrow_charset = arg;
638       break;
639
640     case OPT_fwide_exec_charset_:
641       cpp_opts->wide_charset = arg;
642       break;
643
644     case OPT_finput_charset_:
645       cpp_opts->input_charset = arg;
646       break;
647
648     case OPT_ftemplate_depth_:
649       max_tinst_depth = value;
650       break;
651
652     case OPT_fvisibility_inlines_hidden:
653       visibility_options.inlines_hidden = value;
654       break;
655
656     case OPT_femit_struct_debug_baseonly:
657       set_struct_debug_option (&global_options, "base");
658       break;
659
660     case OPT_femit_struct_debug_reduced:
661       set_struct_debug_option (&global_options,
662                                "dir:ord:sys,dir:gen:any,ind:base");
663       break;
664
665     case OPT_femit_struct_debug_detailed_:
666       set_struct_debug_option (&global_options, arg);
667       break;
668
669     case OPT_idirafter:
670       add_path (xstrdup (arg), AFTER, 0, true);
671       break;
672
673     case OPT_imacros:
674     case OPT_include:
675       defer_opt (code, arg);
676       break;
677
678     case OPT_imultilib:
679       imultilib = arg;
680       break;
681
682     case OPT_iprefix:
683       iprefix = arg;
684       break;
685
686     case OPT_iquote:
687       add_path (xstrdup (arg), QUOTE, 0, true);
688       break;
689
690     case OPT_isysroot:
691       sysroot = arg;
692       break;
693
694     case OPT_isystem:
695       add_path (xstrdup (arg), SYSTEM, 0, true);
696       break;
697
698     case OPT_iwithprefix:
699       add_prefixed_path (arg, SYSTEM);
700       break;
701
702     case OPT_iwithprefixbefore:
703       add_prefixed_path (arg, BRACKET);
704       break;
705
706     case OPT_lang_asm:
707       cpp_set_lang (parse_in, CLK_ASM);
708       cpp_opts->dollars_in_ident = false;
709       break;
710
711     case OPT_nostdinc:
712       std_inc = false;
713       break;
714
715     case OPT_nostdinc__:
716       std_cxx_inc = false;
717       break;
718
719     case OPT_o:
720       if (!out_fname)
721         out_fname = arg;
722       else
723         error ("output filename specified twice");
724       break;
725
726       /* We need to handle the -pedantic switches here, rather than in
727          c_common_post_options, so that a subsequent -Wno-endif-labels
728          is not overridden.  */
729     case OPT_pedantic_errors:
730     case OPT_pedantic:
731       cpp_opts->cpp_pedantic = 1;
732       cpp_opts->warn_endif_labels = 1;
733       if (warn_pointer_sign == -1)
734         warn_pointer_sign = 1;
735       if (warn_overlength_strings == -1)
736         warn_overlength_strings = 1;
737       if (warn_main == -1)
738         warn_main = 2;
739       break;
740
741     case OPT_print_objc_runtime_info:
742       print_struct_values = 1;
743       break;
744
745     case OPT_remap:
746       cpp_opts->remap = 1;
747       break;
748
749     case OPT_std_c__98:
750     case OPT_std_gnu__98:
751       if (!preprocessing_asm_p)
752         set_std_cxx98 (code == OPT_std_c__98 /* ISO */);
753       break;
754
755     case OPT_std_c__0x:
756     case OPT_std_gnu__0x:
757       if (!preprocessing_asm_p)
758         set_std_cxx0x (code == OPT_std_c__0x /* ISO */);
759       break;
760
761     case OPT_std_c90:
762     case OPT_std_iso9899_199409:
763       if (!preprocessing_asm_p)
764         set_std_c89 (code == OPT_std_iso9899_199409 /* c94 */, true /* ISO */);
765       break;
766
767     case OPT_std_gnu90:
768       if (!preprocessing_asm_p)
769         set_std_c89 (false /* c94 */, false /* ISO */);
770       break;
771
772     case OPT_std_c99:
773       if (!preprocessing_asm_p)
774         set_std_c99 (true /* ISO */);
775       break;
776
777     case OPT_std_gnu99:
778       if (!preprocessing_asm_p)
779         set_std_c99 (false /* ISO */);
780       break;
781
782     case OPT_std_c1x:
783       if (!preprocessing_asm_p)
784         set_std_c1x (true /* ISO */);
785       break;
786
787     case OPT_std_gnu1x:
788       if (!preprocessing_asm_p)
789         set_std_c1x (false /* ISO */);
790       break;
791
792     case OPT_trigraphs:
793       cpp_opts->trigraphs = 1;
794       break;
795
796     case OPT_traditional_cpp:
797       cpp_opts->traditional = 1;
798       break;
799
800     case OPT_v:
801       verbose = true;
802       break;
803
804     case OPT_Wabi:
805       warn_psabi = value;
806       break;
807     }
808
809   return result;
810 }
811
812 /* Post-switch processing.  */
813 bool
814 c_common_post_options (const char **pfilename)
815 {
816   struct cpp_callbacks *cb;
817
818   /* Canonicalize the input and output filenames.  */
819   if (in_fnames == NULL)
820     {
821       in_fnames = XNEWVEC (const char *, 1);
822       in_fnames[0] = "";
823     }
824   else if (strcmp (in_fnames[0], "-") == 0)
825     in_fnames[0] = "";
826
827   if (out_fname == NULL || !strcmp (out_fname, "-"))
828     out_fname = "";
829
830   if (cpp_opts->deps.style == DEPS_NONE)
831     check_deps_environment_vars ();
832
833   handle_deferred_opts ();
834
835   sanitize_cpp_opts ();
836
837   register_include_chains (parse_in, sysroot, iprefix, imultilib,
838                            std_inc, std_cxx_inc && c_dialect_cxx (), verbose);
839
840 #ifdef C_COMMON_OVERRIDE_OPTIONS
841   /* Some machines may reject certain combinations of C
842      language-specific options.  */
843   C_COMMON_OVERRIDE_OPTIONS;
844 #endif
845
846   /* Excess precision other than "fast" requires front-end
847      support.  */
848   if (c_dialect_cxx ())
849     {
850       if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD
851           && TARGET_FLT_EVAL_METHOD_NON_DEFAULT)
852         sorry ("-fexcess-precision=standard for C++");
853       flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
854     }
855   else if (flag_excess_precision_cmdline == EXCESS_PRECISION_DEFAULT)
856     flag_excess_precision_cmdline = (flag_iso
857                                      ? EXCESS_PRECISION_STANDARD
858                                      : EXCESS_PRECISION_FAST);
859
860   /* By default we use C99 inline semantics in GNU99 or C99 mode.  C99
861      inline semantics are not supported in GNU89 or C89 mode.  */
862   if (flag_gnu89_inline == -1)
863     flag_gnu89_inline = !flag_isoc99;
864   else if (!flag_gnu89_inline && !flag_isoc99)
865     error ("-fno-gnu89-inline is only supported in GNU99 or C99 mode");
866
867   /* Default to ObjC sjlj exception handling if NeXT runtime.  */
868   if (flag_objc_sjlj_exceptions < 0)
869     flag_objc_sjlj_exceptions = flag_next_runtime;
870   if (flag_objc_exceptions && !flag_objc_sjlj_exceptions)
871     flag_exceptions = 1;
872
873   /* -Wextra implies the following flags
874      unless explicitly overridden.  */
875   if (warn_type_limits == -1)
876     warn_type_limits = extra_warnings;
877   if (warn_clobbered == -1)
878     warn_clobbered = extra_warnings;
879   if (warn_empty_body == -1)
880     warn_empty_body = extra_warnings;
881   if (warn_sign_compare == -1)
882     warn_sign_compare = extra_warnings;
883   if (warn_missing_field_initializers == -1)
884     warn_missing_field_initializers = extra_warnings;
885   if (warn_missing_parameter_type == -1)
886     warn_missing_parameter_type = extra_warnings;
887   if (warn_old_style_declaration == -1)
888     warn_old_style_declaration = extra_warnings;
889   if (warn_override_init == -1)
890     warn_override_init = extra_warnings;
891   if (warn_ignored_qualifiers == -1)
892     warn_ignored_qualifiers = extra_warnings;
893
894   /* -Wpointer-sign is disabled by default, but it is enabled if any
895      of -Wall or -pedantic are given.  */
896   if (warn_pointer_sign == -1)
897     warn_pointer_sign = 0;
898
899   if (warn_strict_aliasing == -1)
900     warn_strict_aliasing = 0;
901   if (warn_strict_overflow == -1)
902     warn_strict_overflow = 0;
903   if (warn_jump_misses_init == -1)
904     warn_jump_misses_init = 0;
905
906   /* -Woverlength-strings is off by default, but is enabled by -pedantic.
907      It is never enabled in C++, as the minimum limit is not normative
908      in that standard.  */
909   if (warn_overlength_strings == -1 || c_dialect_cxx ())
910     warn_overlength_strings = 0;
911
912   /* Wmain is enabled by default in C++ but not in C.  */
913   /* Wmain is disabled by default for -ffreestanding (!flag_hosted),
914      even if -Wall was given (warn_main will be 2 if set by -Wall, 1
915      if set by -Wmain).  */
916   if (warn_main == -1)
917     warn_main = (c_dialect_cxx () && flag_hosted) ? 1 : 0;
918   else if (warn_main == 2)
919     warn_main = flag_hosted ? 1 : 0;
920
921   /* In C, -Wconversion enables -Wsign-conversion (unless disabled
922      through -Wno-sign-conversion). While in C++,
923      -Wsign-conversion needs to be requested explicitly.  */
924   if (warn_sign_conversion == -1)
925     warn_sign_conversion =  (c_dialect_cxx ()) ? 0 : warn_conversion;
926
927   /* In C, -Wall and -Wc++-compat enable -Wenum-compare, which we do
928      in c_common_handle_option; if it has not yet been set, it is
929      disabled by default.  In C++, it is enabled by default.  */
930   if (warn_enum_compare == -1)
931     warn_enum_compare = c_dialect_cxx () ? 1 : 0;
932
933   /* -Wpacked-bitfield-compat is on by default for the C languages.  The
934      warning is issued in stor-layout.c which is not part of the front-end so
935      we need to selectively turn it on here.  */
936   if (warn_packed_bitfield_compat == -1)
937     warn_packed_bitfield_compat = 1;
938
939   /* Special format checking options don't work without -Wformat; warn if
940      they are used.  */
941   if (!warn_format)
942     {
943       warning (OPT_Wformat_y2k,
944                "-Wformat-y2k ignored without -Wformat");
945       warning (OPT_Wformat_extra_args,
946                "-Wformat-extra-args ignored without -Wformat");
947       warning (OPT_Wformat_zero_length,
948                "-Wformat-zero-length ignored without -Wformat");
949       warning (OPT_Wformat_nonliteral,
950                "-Wformat-nonliteral ignored without -Wformat");
951       warning (OPT_Wformat_contains_nul,
952                "-Wformat-contains-nul ignored without -Wformat");
953       warning (OPT_Wformat_security,
954                "-Wformat-security ignored without -Wformat");
955     }
956
957   if (warn_implicit == -1)
958     warn_implicit = 0;
959       
960   if (warn_implicit_int == -1)
961     warn_implicit_int = 0;
962
963   /* -Wimplicit-function-declaration is enabled by default for C99.  */
964   if (warn_implicit_function_declaration == -1)
965     warn_implicit_function_declaration = flag_isoc99;
966
967   /* If we're allowing C++0x constructs, don't warn about C++0x
968      compatibility problems.  */
969   if (cxx_dialect == cxx0x)
970     warn_cxx0x_compat = 0;
971
972   if (flag_preprocess_only)
973     {
974       /* Open the output now.  We must do so even if flag_no_output is
975          on, because there may be other output than from the actual
976          preprocessing (e.g. from -dM).  */
977       if (out_fname[0] == '\0')
978         out_stream = stdout;
979       else
980         out_stream = fopen (out_fname, "w");
981
982       if (out_stream == NULL)
983         {
984           fatal_error ("opening output file %s: %m", out_fname);
985           return false;
986         }
987
988       if (num_in_fnames > 1)
989         error ("too many filenames given.  Type %s --help for usage",
990                progname);
991
992       init_pp_output (out_stream);
993     }
994   else
995     {
996       init_c_lex ();
997
998       /* Yuk.  WTF is this?  I do know ObjC relies on it somewhere.  */
999       input_location = UNKNOWN_LOCATION;
1000     }
1001
1002   cb = cpp_get_callbacks (parse_in);
1003   cb->file_change = cb_file_change;
1004   cb->dir_change = cb_dir_change;
1005   cpp_post_options (parse_in);
1006
1007   input_location = UNKNOWN_LOCATION;
1008
1009   *pfilename = this_input_filename
1010     = cpp_read_main_file (parse_in, in_fnames[0]);
1011   /* Don't do any compilation or preprocessing if there is no input file.  */
1012   if (this_input_filename == NULL)
1013     {
1014       errorcount++;
1015       return false;
1016     }
1017
1018   if (flag_working_directory
1019       && flag_preprocess_only && !flag_no_line_commands)
1020     pp_dir_change (parse_in, get_src_pwd ());
1021
1022   return flag_preprocess_only;
1023 }
1024
1025 /* Front end initialization common to C, ObjC and C++.  */
1026 bool
1027 c_common_init (void)
1028 {
1029   /* Set up preprocessor arithmetic.  Must be done after call to
1030      c_common_nodes_and_builtins for type nodes to be good.  */
1031   cpp_opts->precision = TYPE_PRECISION (intmax_type_node);
1032   cpp_opts->char_precision = TYPE_PRECISION (char_type_node);
1033   cpp_opts->int_precision = TYPE_PRECISION (integer_type_node);
1034   cpp_opts->wchar_precision = TYPE_PRECISION (wchar_type_node);
1035   cpp_opts->unsigned_wchar = TYPE_UNSIGNED (wchar_type_node);
1036   cpp_opts->bytes_big_endian = BYTES_BIG_ENDIAN;
1037
1038   /* This can't happen until after wchar_precision and bytes_big_endian
1039      are known.  */
1040   cpp_init_iconv (parse_in);
1041
1042   if (version_flag)
1043     c_common_print_pch_checksum (stderr);
1044
1045   /* Has to wait until now so that cpplib has its hash table.  */
1046   init_pragma ();
1047
1048   if (flag_preprocess_only)
1049     {
1050       finish_options ();
1051       preprocess_file (parse_in);
1052       return false;
1053     }
1054
1055   return true;
1056 }
1057
1058 /* Initialize the integrated preprocessor after debug output has been
1059    initialized; loop over each input file.  */
1060 void
1061 c_common_parse_file (void)
1062 {
1063   unsigned int i;
1064
1065   i = 0;
1066   for (;;)
1067     {
1068       finish_options ();
1069       pch_init ();
1070       push_file_scope ();
1071       c_parse_file ();
1072       pop_file_scope ();
1073       /* And end the main input file, if the debug writer wants it  */
1074       if (debug_hooks->start_end_main_source_file)
1075         (*debug_hooks->end_source_file) (0);
1076       if (++i >= num_in_fnames)
1077         break;
1078       cpp_undef_all (parse_in);
1079       cpp_clear_file_cache (parse_in);
1080       this_input_filename
1081         = cpp_read_main_file (parse_in, in_fnames[i]);
1082       /* If an input file is missing, abandon further compilation.
1083          cpplib has issued a diagnostic.  */
1084       if (!this_input_filename)
1085         break;
1086     }
1087 }
1088
1089 /* Common finish hook for the C, ObjC and C++ front ends.  */
1090 void
1091 c_common_finish (void)
1092 {
1093   FILE *deps_stream = NULL;
1094
1095   /* Don't write the deps file if there are errors.  */
1096   if (cpp_opts->deps.style != DEPS_NONE && !seen_error ())
1097     {
1098       /* If -M or -MM was seen without -MF, default output to the
1099          output stream.  */
1100       if (!deps_file)
1101         deps_stream = out_stream;
1102       else
1103         {
1104           deps_stream = fopen (deps_file, deps_append ? "a": "w");
1105           if (!deps_stream)
1106             fatal_error ("opening dependency file %s: %m", deps_file);
1107         }
1108     }
1109
1110   /* For performance, avoid tearing down cpplib's internal structures
1111      with cpp_destroy ().  */
1112   cpp_finish (parse_in, deps_stream);
1113
1114   if (deps_stream && deps_stream != out_stream
1115       && (ferror (deps_stream) || fclose (deps_stream)))
1116     fatal_error ("closing dependency file %s: %m", deps_file);
1117
1118   if (out_stream && (ferror (out_stream) || fclose (out_stream)))
1119     fatal_error ("when writing output to %s: %m", out_fname);
1120 }
1121
1122 /* Either of two environment variables can specify output of
1123    dependencies.  Their value is either "OUTPUT_FILE" or "OUTPUT_FILE
1124    DEPS_TARGET", where OUTPUT_FILE is the file to write deps info to
1125    and DEPS_TARGET is the target to mention in the deps.  They also
1126    result in dependency information being appended to the output file
1127    rather than overwriting it, and like Sun's compiler
1128    SUNPRO_DEPENDENCIES suppresses the dependency on the main file.  */
1129 static void
1130 check_deps_environment_vars (void)
1131 {
1132   char *spec;
1133
1134   GET_ENVIRONMENT (spec, "DEPENDENCIES_OUTPUT");
1135   if (spec)
1136     cpp_opts->deps.style = DEPS_USER;
1137   else
1138     {
1139       GET_ENVIRONMENT (spec, "SUNPRO_DEPENDENCIES");
1140       if (spec)
1141         {
1142           cpp_opts->deps.style = DEPS_SYSTEM;
1143           cpp_opts->deps.ignore_main_file = true;
1144         }
1145     }
1146
1147   if (spec)
1148     {
1149       /* Find the space before the DEPS_TARGET, if there is one.  */
1150       char *s = strchr (spec, ' ');
1151       if (s)
1152         {
1153           /* Let the caller perform MAKE quoting.  */
1154           defer_opt (OPT_MT, s + 1);
1155           *s = '\0';
1156         }
1157
1158       /* Command line -MF overrides environment variables and default.  */
1159       if (!deps_file)
1160         deps_file = spec;
1161
1162       deps_append = 1;
1163       deps_seen = true;
1164     }
1165 }
1166
1167 /* Handle deferred command line switches.  */
1168 static void
1169 handle_deferred_opts (void)
1170 {
1171   size_t i;
1172   struct deps *deps;
1173
1174   /* Avoid allocating the deps buffer if we don't need it.
1175      (This flag may be true without there having been -MT or -MQ
1176      options, but we'll still need the deps buffer.)  */
1177   if (!deps_seen)
1178     return;
1179
1180   deps = cpp_get_deps (parse_in);
1181
1182   for (i = 0; i < deferred_count; i++)
1183     {
1184       struct deferred_opt *opt = &deferred_opts[i];
1185
1186       if (opt->code == OPT_MT || opt->code == OPT_MQ)
1187         deps_add_target (deps, opt->arg, opt->code == OPT_MQ);
1188     }
1189 }
1190
1191 /* These settings are appropriate for GCC, but not necessarily so for
1192    cpplib as a library.  */
1193 static void
1194 sanitize_cpp_opts (void)
1195 {
1196   /* If we don't know what style of dependencies to output, complain
1197      if any other dependency switches have been given.  */
1198   if (deps_seen && cpp_opts->deps.style == DEPS_NONE)
1199     error ("to generate dependencies you must specify either -M or -MM");
1200
1201   /* -dM and dependencies suppress normal output; do it here so that
1202      the last -d[MDN] switch overrides earlier ones.  */
1203   if (flag_dump_macros == 'M')
1204     flag_no_output = 1;
1205
1206   /* By default, -fdirectives-only implies -dD.  This allows subsequent phases
1207      to perform proper macro expansion.  */
1208   if (cpp_opts->directives_only && !cpp_opts->preprocessed && !flag_dump_macros)
1209     flag_dump_macros = 'D';
1210
1211   /* Disable -dD, -dN and -dI if normal output is suppressed.  Allow
1212      -dM since at least glibc relies on -M -dM to work.  */
1213   /* Also, flag_no_output implies flag_no_line_commands, always.  */
1214   if (flag_no_output)
1215     {
1216       if (flag_dump_macros != 'M')
1217         flag_dump_macros = 0;
1218       flag_dump_includes = 0;
1219       flag_no_line_commands = 1;
1220     }
1221   else if (cpp_opts->deps.missing_files)
1222     error ("-MG may only be used with -M or -MM");
1223
1224   cpp_opts->unsigned_char = !flag_signed_char;
1225   cpp_opts->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;
1226
1227   /* Wlong-long is disabled by default. It is enabled by:
1228       [-pedantic | -Wtraditional] -std=[gnu|c]++98 ; or
1229       [-pedantic | -Wtraditional] -std=non-c99 .
1230
1231       Either -Wlong-long or -Wno-long-long override any other settings.  */
1232   if (warn_long_long == -1)
1233     warn_long_long = ((pedantic || warn_traditional)
1234                       && (c_dialect_cxx () ? cxx_dialect == cxx98 : !flag_isoc99));
1235   cpp_opts->cpp_warn_long_long = warn_long_long;
1236
1237   /* Similarly with -Wno-variadic-macros.  No check for c99 here, since
1238      this also turns off warnings about GCCs extension.  */
1239   cpp_opts->warn_variadic_macros
1240     = warn_variadic_macros && (pedantic || warn_traditional);
1241
1242   /* If we're generating preprocessor output, emit current directory
1243      if explicitly requested or if debugging information is enabled.
1244      ??? Maybe we should only do it for debugging formats that
1245      actually output the current directory?  */
1246   if (flag_working_directory == -1)
1247     flag_working_directory = (debug_info_level != DINFO_LEVEL_NONE);
1248
1249   if (cpp_opts->directives_only)
1250     {
1251       if (warn_unused_macros)
1252         error ("-fdirectives-only is incompatible with -Wunused_macros");
1253       if (cpp_opts->traditional)
1254         error ("-fdirectives-only is incompatible with -traditional");
1255     }
1256 }
1257
1258 /* Add include path with a prefix at the front of its name.  */
1259 static void
1260 add_prefixed_path (const char *suffix, size_t chain)
1261 {
1262   char *path;
1263   const char *prefix;
1264   size_t prefix_len, suffix_len;
1265
1266   suffix_len = strlen (suffix);
1267   prefix     = iprefix ? iprefix : cpp_GCC_INCLUDE_DIR;
1268   prefix_len = iprefix ? strlen (iprefix) : cpp_GCC_INCLUDE_DIR_len;
1269
1270   path = (char *) xmalloc (prefix_len + suffix_len + 1);
1271   memcpy (path, prefix, prefix_len);
1272   memcpy (path + prefix_len, suffix, suffix_len);
1273   path[prefix_len + suffix_len] = '\0';
1274
1275   add_path (path, chain, 0, false);
1276 }
1277
1278 /* Handle -D, -U, -A, -imacros, and the first -include.  */
1279 static void
1280 finish_options (void)
1281 {
1282   if (!cpp_opts->preprocessed)
1283     {
1284       size_t i;
1285
1286       cb_file_change (parse_in,
1287                       linemap_add (line_table, LC_RENAME, 0,
1288                                    _("<built-in>"), 0));
1289
1290       cpp_init_builtins (parse_in, flag_hosted);
1291       c_cpp_builtins (parse_in);
1292
1293       /* We're about to send user input to cpplib, so make it warn for
1294          things that we previously (when we sent it internal definitions)
1295          told it to not warn.
1296
1297          C99 permits implementation-defined characters in identifiers.
1298          The documented meaning of -std= is to turn off extensions that
1299          conflict with the specified standard, and since a strictly
1300          conforming program cannot contain a '$', we do not condition
1301          their acceptance on the -std= setting.  */
1302       cpp_opts->warn_dollars = (cpp_opts->cpp_pedantic && !cpp_opts->c99);
1303
1304       cb_file_change (parse_in,
1305                       linemap_add (line_table, LC_RENAME, 0,
1306                                    _("<command-line>"), 0));
1307
1308       for (i = 0; i < deferred_count; i++)
1309         {
1310           struct deferred_opt *opt = &deferred_opts[i];
1311
1312           if (opt->code == OPT_D)
1313             cpp_define (parse_in, opt->arg);
1314           else if (opt->code == OPT_U)
1315             cpp_undef (parse_in, opt->arg);
1316           else if (opt->code == OPT_A)
1317             {
1318               if (opt->arg[0] == '-')
1319                 cpp_unassert (parse_in, opt->arg + 1);
1320               else
1321                 cpp_assert (parse_in, opt->arg);
1322             }
1323         }
1324
1325       /* Start the main input file, if the debug writer wants it. */
1326       if (debug_hooks->start_end_main_source_file
1327           && !flag_preprocess_only)
1328         (*debug_hooks->start_source_file) (0, this_input_filename);
1329
1330       /* Handle -imacros after -D and -U.  */
1331       for (i = 0; i < deferred_count; i++)
1332         {
1333           struct deferred_opt *opt = &deferred_opts[i];
1334
1335           if (opt->code == OPT_imacros
1336               && cpp_push_include (parse_in, opt->arg))
1337             {
1338               /* Disable push_command_line_include callback for now.  */
1339               include_cursor = deferred_count + 1;
1340               cpp_scan_nooutput (parse_in);
1341             }
1342         }
1343     }
1344   else
1345     {
1346       if (cpp_opts->directives_only)
1347         cpp_init_special_builtins (parse_in);
1348
1349       /* Start the main input file, if the debug writer wants it. */
1350       if (debug_hooks->start_end_main_source_file
1351           && !flag_preprocess_only)
1352         (*debug_hooks->start_source_file) (0, this_input_filename);
1353     }
1354
1355   include_cursor = 0;
1356   push_command_line_include ();
1357 }
1358
1359 /* Give CPP the next file given by -include, if any.  */
1360 static void
1361 push_command_line_include (void)
1362 {
1363   while (include_cursor < deferred_count)
1364     {
1365       struct deferred_opt *opt = &deferred_opts[include_cursor++];
1366
1367       if (!cpp_opts->preprocessed && opt->code == OPT_include
1368           && cpp_push_include (parse_in, opt->arg))
1369         return;
1370     }
1371
1372   if (include_cursor == deferred_count)
1373     {
1374       include_cursor++;
1375       /* -Wunused-macros should only warn about macros defined hereafter.  */
1376       cpp_opts->warn_unused_macros = warn_unused_macros;
1377       /* Restore the line map from <command line>.  */
1378       if (!cpp_opts->preprocessed)
1379         cpp_change_file (parse_in, LC_RENAME, this_input_filename);
1380
1381       /* Set this here so the client can change the option if it wishes,
1382          and after stacking the main file so we don't trace the main file.  */
1383       line_table->trace_includes = cpp_opts->print_include_names;
1384     }
1385 }
1386
1387 /* File change callback.  Has to handle -include files.  */
1388 static void
1389 cb_file_change (cpp_reader * ARG_UNUSED (pfile),
1390                 const struct line_map *new_map)
1391 {
1392   if (flag_preprocess_only)
1393     pp_file_change (new_map);
1394   else
1395     fe_file_change (new_map);
1396
1397   if (new_map == 0 || (new_map->reason == LC_LEAVE && MAIN_FILE_P (new_map)))
1398     push_command_line_include ();
1399 }
1400
1401 void
1402 cb_dir_change (cpp_reader * ARG_UNUSED (pfile), const char *dir)
1403 {
1404   if (!set_src_pwd (dir))
1405     warning (0, "too late for # directive to set debug directory");
1406 }
1407
1408 /* Set the C 89 standard (with 1994 amendments if C94, without GNU
1409    extensions if ISO).  There is no concept of gnu94.  */
1410 static void
1411 set_std_c89 (int c94, int iso)
1412 {
1413   cpp_set_lang (parse_in, c94 ? CLK_STDC94: iso ? CLK_STDC89: CLK_GNUC89);
1414   flag_iso = iso;
1415   flag_no_asm = iso;
1416   flag_no_gnu_keywords = iso;
1417   flag_no_nonansi_builtin = iso;
1418   flag_isoc94 = c94;
1419   flag_isoc99 = 0;
1420   flag_isoc1x = 0;
1421 }
1422
1423 /* Set the C 99 standard (without GNU extensions if ISO).  */
1424 static void
1425 set_std_c99 (int iso)
1426 {
1427   cpp_set_lang (parse_in, iso ? CLK_STDC99: CLK_GNUC99);
1428   flag_no_asm = iso;
1429   flag_no_nonansi_builtin = iso;
1430   flag_iso = iso;
1431   flag_isoc1x = 0;
1432   flag_isoc99 = 1;
1433   flag_isoc94 = 1;
1434 }
1435
1436 /* Set the C 1X standard draft (without GNU extensions if ISO).  */
1437 static void
1438 set_std_c1x (int iso)
1439 {
1440   cpp_set_lang (parse_in, iso ? CLK_STDC1X: CLK_GNUC1X);
1441   flag_no_asm = iso;
1442   flag_no_nonansi_builtin = iso;
1443   flag_iso = iso;
1444   flag_isoc1x = 1;
1445   flag_isoc99 = 1;
1446   flag_isoc94 = 1;
1447 }
1448
1449 /* Set the C++ 98 standard (without GNU extensions if ISO).  */
1450 static void
1451 set_std_cxx98 (int iso)
1452 {
1453   cpp_set_lang (parse_in, iso ? CLK_CXX98: CLK_GNUCXX);
1454   flag_no_gnu_keywords = iso;
1455   flag_no_nonansi_builtin = iso;
1456   flag_iso = iso;
1457   cxx_dialect = cxx98;
1458 }
1459
1460 /* Set the C++ 0x working draft "standard" (without GNU extensions if ISO).  */
1461 static void
1462 set_std_cxx0x (int iso)
1463 {
1464   cpp_set_lang (parse_in, iso ? CLK_CXX0X: CLK_GNUCXX0X);
1465   flag_no_gnu_keywords = iso;
1466   flag_no_nonansi_builtin = iso;
1467   flag_iso = iso;
1468   cxx_dialect = cxx0x;
1469 }
1470
1471 /* Args to -d specify what to dump.  Silently ignore
1472    unrecognized options; they may be aimed at toplev.c.  */
1473 static void
1474 handle_OPT_d (const char *arg)
1475 {
1476   char c;
1477
1478   while ((c = *arg++) != '\0')
1479     switch (c)
1480       {
1481       case 'M':                 /* Dump macros only.  */
1482       case 'N':                 /* Dump names.  */
1483       case 'D':                 /* Dump definitions.  */
1484       case 'U':                 /* Dump used macros.  */
1485         flag_dump_macros = c;
1486         break;
1487
1488       case 'I':
1489         flag_dump_includes = 1;
1490         break;
1491       }
1492 }