comparison gcc/c-family/c-opts.c @ 68:561a7518be6b

update gcc-4.6
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Sun, 21 Aug 2011 07:07:55 +0900
parents
children 04ced10e8804
comparison
equal deleted inserted replaced
67:f6334be47118 68:561a7518be6b
1 /* C/ObjC/C++ command line option handling.
2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
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 c_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, loc, "base");
658 break;
659
660 case OPT_femit_struct_debug_reduced:
661 set_struct_debug_option (&global_options, loc,
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, loc, 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 /* When writing a PCH file, avoid reading some other PCH file,
999 because the default address space slot then can't be used
1000 for the output PCH file. */
1001 if (pch_file)
1002 c_common_no_more_pch ();
1003
1004 /* Yuk. WTF is this? I do know ObjC relies on it somewhere. */
1005 input_location = UNKNOWN_LOCATION;
1006 }
1007
1008 cb = cpp_get_callbacks (parse_in);
1009 cb->file_change = cb_file_change;
1010 cb->dir_change = cb_dir_change;
1011 cpp_post_options (parse_in);
1012
1013 input_location = UNKNOWN_LOCATION;
1014
1015 *pfilename = this_input_filename
1016 = cpp_read_main_file (parse_in, in_fnames[0]);
1017 /* Don't do any compilation or preprocessing if there is no input file. */
1018 if (this_input_filename == NULL)
1019 {
1020 errorcount++;
1021 return false;
1022 }
1023
1024 if (flag_working_directory
1025 && flag_preprocess_only && !flag_no_line_commands)
1026 pp_dir_change (parse_in, get_src_pwd ());
1027
1028 return flag_preprocess_only;
1029 }
1030
1031 /* Front end initialization common to C, ObjC and C++. */
1032 bool
1033 c_common_init (void)
1034 {
1035 /* Set up preprocessor arithmetic. Must be done after call to
1036 c_common_nodes_and_builtins for type nodes to be good. */
1037 cpp_opts->precision = TYPE_PRECISION (intmax_type_node);
1038 cpp_opts->char_precision = TYPE_PRECISION (char_type_node);
1039 cpp_opts->int_precision = TYPE_PRECISION (integer_type_node);
1040 cpp_opts->wchar_precision = TYPE_PRECISION (wchar_type_node);
1041 cpp_opts->unsigned_wchar = TYPE_UNSIGNED (wchar_type_node);
1042 cpp_opts->bytes_big_endian = BYTES_BIG_ENDIAN;
1043
1044 /* This can't happen until after wchar_precision and bytes_big_endian
1045 are known. */
1046 cpp_init_iconv (parse_in);
1047
1048 if (version_flag)
1049 c_common_print_pch_checksum (stderr);
1050
1051 /* Has to wait until now so that cpplib has its hash table. */
1052 init_pragma ();
1053
1054 if (flag_preprocess_only)
1055 {
1056 c_finish_options ();
1057 preprocess_file (parse_in);
1058 return false;
1059 }
1060
1061 return true;
1062 }
1063
1064 /* Initialize the integrated preprocessor after debug output has been
1065 initialized; loop over each input file. */
1066 void
1067 c_common_parse_file (void)
1068 {
1069 unsigned int i;
1070
1071 i = 0;
1072 for (;;)
1073 {
1074 c_finish_options ();
1075 pch_init ();
1076 push_file_scope ();
1077 c_parse_file ();
1078 pop_file_scope ();
1079 /* And end the main input file, if the debug writer wants it */
1080 if (debug_hooks->start_end_main_source_file)
1081 (*debug_hooks->end_source_file) (0);
1082 if (++i >= num_in_fnames)
1083 break;
1084 cpp_undef_all (parse_in);
1085 cpp_clear_file_cache (parse_in);
1086 this_input_filename
1087 = cpp_read_main_file (parse_in, in_fnames[i]);
1088 /* If an input file is missing, abandon further compilation.
1089 cpplib has issued a diagnostic. */
1090 if (!this_input_filename)
1091 break;
1092 }
1093 }
1094
1095 /* Common finish hook for the C, ObjC and C++ front ends. */
1096 void
1097 c_common_finish (void)
1098 {
1099 FILE *deps_stream = NULL;
1100
1101 /* Don't write the deps file if there are errors. */
1102 if (cpp_opts->deps.style != DEPS_NONE && !seen_error ())
1103 {
1104 /* If -M or -MM was seen without -MF, default output to the
1105 output stream. */
1106 if (!deps_file)
1107 deps_stream = out_stream;
1108 else
1109 {
1110 deps_stream = fopen (deps_file, deps_append ? "a": "w");
1111 if (!deps_stream)
1112 fatal_error ("opening dependency file %s: %m", deps_file);
1113 }
1114 }
1115
1116 /* For performance, avoid tearing down cpplib's internal structures
1117 with cpp_destroy (). */
1118 cpp_finish (parse_in, deps_stream);
1119
1120 if (deps_stream && deps_stream != out_stream
1121 && (ferror (deps_stream) || fclose (deps_stream)))
1122 fatal_error ("closing dependency file %s: %m", deps_file);
1123
1124 if (out_stream && (ferror (out_stream) || fclose (out_stream)))
1125 fatal_error ("when writing output to %s: %m", out_fname);
1126 }
1127
1128 /* Either of two environment variables can specify output of
1129 dependencies. Their value is either "OUTPUT_FILE" or "OUTPUT_FILE
1130 DEPS_TARGET", where OUTPUT_FILE is the file to write deps info to
1131 and DEPS_TARGET is the target to mention in the deps. They also
1132 result in dependency information being appended to the output file
1133 rather than overwriting it, and like Sun's compiler
1134 SUNPRO_DEPENDENCIES suppresses the dependency on the main file. */
1135 static void
1136 check_deps_environment_vars (void)
1137 {
1138 char *spec;
1139
1140 spec = getenv ("DEPENDENCIES_OUTPUT");
1141 if (spec)
1142 cpp_opts->deps.style = DEPS_USER;
1143 else
1144 {
1145 spec = getenv ("SUNPRO_DEPENDENCIES");
1146 if (spec)
1147 {
1148 cpp_opts->deps.style = DEPS_SYSTEM;
1149 cpp_opts->deps.ignore_main_file = true;
1150 }
1151 }
1152
1153 if (spec)
1154 {
1155 /* Find the space before the DEPS_TARGET, if there is one. */
1156 char *s = strchr (spec, ' ');
1157 if (s)
1158 {
1159 /* Let the caller perform MAKE quoting. */
1160 defer_opt (OPT_MT, s + 1);
1161 *s = '\0';
1162 }
1163
1164 /* Command line -MF overrides environment variables and default. */
1165 if (!deps_file)
1166 deps_file = spec;
1167
1168 deps_append = 1;
1169 deps_seen = true;
1170 }
1171 }
1172
1173 /* Handle deferred command line switches. */
1174 static void
1175 handle_deferred_opts (void)
1176 {
1177 size_t i;
1178 struct deps *deps;
1179
1180 /* Avoid allocating the deps buffer if we don't need it.
1181 (This flag may be true without there having been -MT or -MQ
1182 options, but we'll still need the deps buffer.) */
1183 if (!deps_seen)
1184 return;
1185
1186 deps = cpp_get_deps (parse_in);
1187
1188 for (i = 0; i < deferred_count; i++)
1189 {
1190 struct deferred_opt *opt = &deferred_opts[i];
1191
1192 if (opt->code == OPT_MT || opt->code == OPT_MQ)
1193 deps_add_target (deps, opt->arg, opt->code == OPT_MQ);
1194 }
1195 }
1196
1197 /* These settings are appropriate for GCC, but not necessarily so for
1198 cpplib as a library. */
1199 static void
1200 sanitize_cpp_opts (void)
1201 {
1202 /* If we don't know what style of dependencies to output, complain
1203 if any other dependency switches have been given. */
1204 if (deps_seen && cpp_opts->deps.style == DEPS_NONE)
1205 error ("to generate dependencies you must specify either -M or -MM");
1206
1207 /* -dM and dependencies suppress normal output; do it here so that
1208 the last -d[MDN] switch overrides earlier ones. */
1209 if (flag_dump_macros == 'M')
1210 flag_no_output = 1;
1211
1212 /* By default, -fdirectives-only implies -dD. This allows subsequent phases
1213 to perform proper macro expansion. */
1214 if (cpp_opts->directives_only && !cpp_opts->preprocessed && !flag_dump_macros)
1215 flag_dump_macros = 'D';
1216
1217 /* Disable -dD, -dN and -dI if normal output is suppressed. Allow
1218 -dM since at least glibc relies on -M -dM to work. */
1219 /* Also, flag_no_output implies flag_no_line_commands, always. */
1220 if (flag_no_output)
1221 {
1222 if (flag_dump_macros != 'M')
1223 flag_dump_macros = 0;
1224 flag_dump_includes = 0;
1225 flag_no_line_commands = 1;
1226 }
1227 else if (cpp_opts->deps.missing_files)
1228 error ("-MG may only be used with -M or -MM");
1229
1230 cpp_opts->unsigned_char = !flag_signed_char;
1231 cpp_opts->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;
1232
1233 /* Wlong-long is disabled by default. It is enabled by:
1234 [-pedantic | -Wtraditional] -std=[gnu|c]++98 ; or
1235 [-pedantic | -Wtraditional] -std=non-c99 .
1236
1237 Either -Wlong-long or -Wno-long-long override any other settings. */
1238 if (warn_long_long == -1)
1239 warn_long_long = ((pedantic || warn_traditional)
1240 && (c_dialect_cxx () ? cxx_dialect == cxx98 : !flag_isoc99));
1241 cpp_opts->cpp_warn_long_long = warn_long_long;
1242
1243 /* Similarly with -Wno-variadic-macros. No check for c99 here, since
1244 this also turns off warnings about GCCs extension. */
1245 cpp_opts->warn_variadic_macros
1246 = warn_variadic_macros && (pedantic || warn_traditional);
1247
1248 /* If we're generating preprocessor output, emit current directory
1249 if explicitly requested or if debugging information is enabled.
1250 ??? Maybe we should only do it for debugging formats that
1251 actually output the current directory? */
1252 if (flag_working_directory == -1)
1253 flag_working_directory = (debug_info_level != DINFO_LEVEL_NONE);
1254
1255 if (cpp_opts->directives_only)
1256 {
1257 if (warn_unused_macros)
1258 error ("-fdirectives-only is incompatible with -Wunused_macros");
1259 if (cpp_opts->traditional)
1260 error ("-fdirectives-only is incompatible with -traditional");
1261 }
1262 }
1263
1264 /* Add include path with a prefix at the front of its name. */
1265 static void
1266 add_prefixed_path (const char *suffix, size_t chain)
1267 {
1268 char *path;
1269 const char *prefix;
1270 size_t prefix_len, suffix_len;
1271
1272 suffix_len = strlen (suffix);
1273 prefix = iprefix ? iprefix : cpp_GCC_INCLUDE_DIR;
1274 prefix_len = iprefix ? strlen (iprefix) : cpp_GCC_INCLUDE_DIR_len;
1275
1276 path = (char *) xmalloc (prefix_len + suffix_len + 1);
1277 memcpy (path, prefix, prefix_len);
1278 memcpy (path + prefix_len, suffix, suffix_len);
1279 path[prefix_len + suffix_len] = '\0';
1280
1281 add_path (path, chain, 0, false);
1282 }
1283
1284 /* Handle -D, -U, -A, -imacros, and the first -include. */
1285 static void
1286 c_finish_options (void)
1287 {
1288 if (!cpp_opts->preprocessed)
1289 {
1290 size_t i;
1291
1292 cb_file_change (parse_in,
1293 linemap_add (line_table, LC_RENAME, 0,
1294 _("<built-in>"), 0));
1295
1296 cpp_init_builtins (parse_in, flag_hosted);
1297 c_cpp_builtins (parse_in);
1298
1299 /* We're about to send user input to cpplib, so make it warn for
1300 things that we previously (when we sent it internal definitions)
1301 told it to not warn.
1302
1303 C99 permits implementation-defined characters in identifiers.
1304 The documented meaning of -std= is to turn off extensions that
1305 conflict with the specified standard, and since a strictly
1306 conforming program cannot contain a '$', we do not condition
1307 their acceptance on the -std= setting. */
1308 cpp_opts->warn_dollars = (cpp_opts->cpp_pedantic && !cpp_opts->c99);
1309
1310 cb_file_change (parse_in,
1311 linemap_add (line_table, LC_RENAME, 0,
1312 _("<command-line>"), 0));
1313
1314 for (i = 0; i < deferred_count; i++)
1315 {
1316 struct deferred_opt *opt = &deferred_opts[i];
1317
1318 if (opt->code == OPT_D)
1319 cpp_define (parse_in, opt->arg);
1320 else if (opt->code == OPT_U)
1321 cpp_undef (parse_in, opt->arg);
1322 else if (opt->code == OPT_A)
1323 {
1324 if (opt->arg[0] == '-')
1325 cpp_unassert (parse_in, opt->arg + 1);
1326 else
1327 cpp_assert (parse_in, opt->arg);
1328 }
1329 }
1330
1331 /* Start the main input file, if the debug writer wants it. */
1332 if (debug_hooks->start_end_main_source_file
1333 && !flag_preprocess_only)
1334 (*debug_hooks->start_source_file) (0, this_input_filename);
1335
1336 /* Handle -imacros after -D and -U. */
1337 for (i = 0; i < deferred_count; i++)
1338 {
1339 struct deferred_opt *opt = &deferred_opts[i];
1340
1341 if (opt->code == OPT_imacros
1342 && cpp_push_include (parse_in, opt->arg))
1343 {
1344 /* Disable push_command_line_include callback for now. */
1345 include_cursor = deferred_count + 1;
1346 cpp_scan_nooutput (parse_in);
1347 }
1348 }
1349 }
1350 else
1351 {
1352 if (cpp_opts->directives_only)
1353 cpp_init_special_builtins (parse_in);
1354
1355 /* Start the main input file, if the debug writer wants it. */
1356 if (debug_hooks->start_end_main_source_file
1357 && !flag_preprocess_only)
1358 (*debug_hooks->start_source_file) (0, this_input_filename);
1359 }
1360
1361 include_cursor = 0;
1362 push_command_line_include ();
1363 }
1364
1365 /* Give CPP the next file given by -include, if any. */
1366 static void
1367 push_command_line_include (void)
1368 {
1369 while (include_cursor < deferred_count)
1370 {
1371 struct deferred_opt *opt = &deferred_opts[include_cursor++];
1372
1373 if (!cpp_opts->preprocessed && opt->code == OPT_include
1374 && cpp_push_include (parse_in, opt->arg))
1375 return;
1376 }
1377
1378 if (include_cursor == deferred_count)
1379 {
1380 include_cursor++;
1381 /* -Wunused-macros should only warn about macros defined hereafter. */
1382 cpp_opts->warn_unused_macros = warn_unused_macros;
1383 /* Restore the line map from <command line>. */
1384 if (!cpp_opts->preprocessed)
1385 cpp_change_file (parse_in, LC_RENAME, this_input_filename);
1386
1387 /* Set this here so the client can change the option if it wishes,
1388 and after stacking the main file so we don't trace the main file. */
1389 line_table->trace_includes = cpp_opts->print_include_names;
1390 }
1391 }
1392
1393 /* File change callback. Has to handle -include files. */
1394 static void
1395 cb_file_change (cpp_reader * ARG_UNUSED (pfile),
1396 const struct line_map *new_map)
1397 {
1398 if (flag_preprocess_only)
1399 pp_file_change (new_map);
1400 else
1401 fe_file_change (new_map);
1402
1403 if (new_map == 0 || (new_map->reason == LC_LEAVE && MAIN_FILE_P (new_map)))
1404 push_command_line_include ();
1405 }
1406
1407 void
1408 cb_dir_change (cpp_reader * ARG_UNUSED (pfile), const char *dir)
1409 {
1410 if (!set_src_pwd (dir))
1411 warning (0, "too late for # directive to set debug directory");
1412 }
1413
1414 /* Set the C 89 standard (with 1994 amendments if C94, without GNU
1415 extensions if ISO). There is no concept of gnu94. */
1416 static void
1417 set_std_c89 (int c94, int iso)
1418 {
1419 cpp_set_lang (parse_in, c94 ? CLK_STDC94: iso ? CLK_STDC89: CLK_GNUC89);
1420 flag_iso = iso;
1421 flag_no_asm = iso;
1422 flag_no_gnu_keywords = iso;
1423 flag_no_nonansi_builtin = iso;
1424 flag_isoc94 = c94;
1425 flag_isoc99 = 0;
1426 flag_isoc1x = 0;
1427 }
1428
1429 /* Set the C 99 standard (without GNU extensions if ISO). */
1430 static void
1431 set_std_c99 (int iso)
1432 {
1433 cpp_set_lang (parse_in, iso ? CLK_STDC99: CLK_GNUC99);
1434 flag_no_asm = iso;
1435 flag_no_nonansi_builtin = iso;
1436 flag_iso = iso;
1437 flag_isoc1x = 0;
1438 flag_isoc99 = 1;
1439 flag_isoc94 = 1;
1440 }
1441
1442 /* Set the C 1X standard draft (without GNU extensions if ISO). */
1443 static void
1444 set_std_c1x (int iso)
1445 {
1446 cpp_set_lang (parse_in, iso ? CLK_STDC1X: CLK_GNUC1X);
1447 flag_no_asm = iso;
1448 flag_no_nonansi_builtin = iso;
1449 flag_iso = iso;
1450 flag_isoc1x = 1;
1451 flag_isoc99 = 1;
1452 flag_isoc94 = 1;
1453 }
1454
1455 /* Set the C++ 98 standard (without GNU extensions if ISO). */
1456 static void
1457 set_std_cxx98 (int iso)
1458 {
1459 cpp_set_lang (parse_in, iso ? CLK_CXX98: CLK_GNUCXX);
1460 flag_no_gnu_keywords = iso;
1461 flag_no_nonansi_builtin = iso;
1462 flag_iso = iso;
1463 cxx_dialect = cxx98;
1464 }
1465
1466 /* Set the C++ 0x working draft "standard" (without GNU extensions if ISO). */
1467 static void
1468 set_std_cxx0x (int iso)
1469 {
1470 cpp_set_lang (parse_in, iso ? CLK_CXX0X: CLK_GNUCXX0X);
1471 flag_no_gnu_keywords = iso;
1472 flag_no_nonansi_builtin = iso;
1473 flag_iso = iso;
1474 cxx_dialect = cxx0x;
1475 }
1476
1477 /* Args to -d specify what to dump. Silently ignore
1478 unrecognized options; they may be aimed at toplev.c. */
1479 static void
1480 handle_OPT_d (const char *arg)
1481 {
1482 char c;
1483
1484 while ((c = *arg++) != '\0')
1485 switch (c)
1486 {
1487 case 'M': /* Dump macros only. */
1488 case 'N': /* Dump names. */
1489 case 'D': /* Dump definitions. */
1490 case 'U': /* Dump used macros. */
1491 flag_dump_macros = c;
1492 break;
1493
1494 case 'I':
1495 flag_dump_includes = 1;
1496 break;
1497 }
1498 }