]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/c-family/c-opts.c
trans.c (check_inlining_for_nested_subprog): Quote reserved names.
[thirdparty/gcc.git] / gcc / c-family / c-opts.c
CommitLineData
0b6f2917 1/* C/ObjC/C++ command line option handling.
a5544970 2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
0b6f2917
NB
3 Contributed by Neil Booth.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9dcd6f09 9Software Foundation; either version 3, or (at your option) any later
0b6f2917
NB
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
9dcd6f09
NC
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
0b6f2917
NB
20
21#include "config.h"
22#include "system.h"
4977bab6 23#include "coretypes.h"
903f5c23 24#include "tm.h"
2adfab87 25#include "c-target.h"
0b6f2917 26#include "c-common.h"
4d0cdd0c 27#include "memmodel.h"
2adfab87
AM
28#include "tm_p.h" /* For C_COMMON_OVERRIDE_OPTIONS. */
29#include "diagnostic.h"
0b6f2917
NB
30#include "c-pragma.h"
31#include "flags.h"
32#include "toplev.h"
33#include "langhooks.h"
18767f65 34#include "tree-diagnostic.h" /* for virt_loc_aware_diagnostic_finalizer */
4b7091eb 35#include "intl.h"
5793b276 36#include "cppdefault.h"
670637ee 37#include "incpath.h"
23345bbb 38#include "debug.h" /* For debug_hooks. */
2772ef3e 39#include "opts.h"
b826515a 40#include "plugin.h" /* For PLUGIN_INCLUDE_FILE event. */
c6e83800 41#include "mkdeps.h"
f8a36c78 42#include "dumpfile.h"
7365279f 43#include "file-prefix-map.h" /* add_*_prefix_map() */
5793b276 44
b1822ccc
NB
45#ifndef DOLLARS_IN_IDENTIFIERS
46# define DOLLARS_IN_IDENTIFIERS true
47#endif
48
5793b276
NB
49#ifndef TARGET_SYSTEM_ROOT
50# define TARGET_SYSTEM_ROOT NULL
51#endif
0b6f2917 52
7cd60054
AM
53#ifndef TARGET_OPTF
54#define TARGET_OPTF(ARG)
55#endif
56
f4ff5a69 57/* CPP's options. */
d2e796ad 58cpp_options *cpp_opts;
18bdccaa 59
460bd0e3 60/* Input filename. */
89e9faee 61static const char *this_input_filename;
460bd0e3 62
76c3e73e
NB
63/* Filename and stream for preprocessed output. */
64static const char *out_fname;
65static FILE *out_stream;
66
67/* Append dependencies to deps_file. */
68static bool deps_append;
69
f4ff5a69
NB
70/* If dependency switches (-MF etc.) have been given. */
71static bool deps_seen;
72
5793b276
NB
73/* If -v seen. */
74static bool verbose;
75
f4ff5a69
NB
76/* Dependency output file. */
77static const char *deps_file;
78
5793b276
NB
79/* The prefix given by -iprefix, if any. */
80static const char *iprefix;
81
2b6dd222
JM
82/* The multilib directory given by -imultilib, if any. */
83static const char *imultilib;
84
5793b276
NB
85/* The system root, if any. Overridden by -isysroot. */
86static const char *sysroot = TARGET_SYSTEM_ROOT;
87
88/* Zero disables all standard directories for headers. */
89static bool std_inc = true;
90
91/* Zero disables the C++-specific standard directories for headers. */
92static bool std_cxx_inc = true;
93
94/* If the quote chain has been split by -I-. */
95static bool quote_chain_split;
96
b86f6cd9
NB
97/* Number of deferred options. */
98static size_t deferred_count;
f4ff5a69 99
23345bbb
NB
100/* Number of deferred options scanned for -include. */
101static size_t include_cursor;
102
f8a36c78
TJ
103/* Dump files/flags to use during parsing. */
104static FILE *original_dump_file = NULL;
1a817418 105static dump_flags_t original_dump_flags;
f8a36c78 106
1efcb8c6
JM
107/* Whether any standard preincluded header has been preincluded. */
108static bool done_preinclude;
109
2f6e4e97
AJ
110static void handle_OPT_d (const char *);
111static void set_std_cxx98 (int);
97e3ad20 112static void set_std_cxx11 (int);
e4276ba5 113static void set_std_cxx14 (int);
7b936140 114static void set_std_cxx17 (int);
026a79f7 115static void set_std_cxx2a (int);
2f6e4e97
AJ
116static void set_std_c89 (int, int);
117static void set_std_c99 (int);
48b0b196 118static void set_std_c11 (int);
c76dc9c3 119static void set_std_c17 (int);
9f936c86 120static void set_std_c2x (int);
2f6e4e97
AJ
121static void check_deps_environment_vars (void);
122static void handle_deferred_opts (void);
123static void sanitize_cpp_opts (void);
b90c9338 124static void add_prefixed_path (const char *, incpath_kind);
2f6e4e97 125static void push_command_line_include (void);
0e50b624 126static void cb_file_change (cpp_reader *, const line_map_ordinary *);
8e9ea4d7 127static void cb_dir_change (cpp_reader *, const char *);
c98cd5bf 128static void c_finish_options (void);
460bd0e3
NB
129
130#ifndef STDC_0_IN_SYSTEM_HEADERS
131#define STDC_0_IN_SYSTEM_HEADERS 0
132#endif
0b6f2917 133
2772ef3e 134/* Holds switches parsed by c_common_handle_option (), but whose
95bd1dd7 135 handling is deferred to c_common_post_options (). */
2f6e4e97 136static void defer_opt (enum opt_code, const char *);
f4ff5a69
NB
137static struct deferred_opt
138{
139 enum opt_code code;
140 const char *arg;
141} *deferred_opts;
142
3734d960 143
c5fa0890 144extern const unsigned int
3734d960
MLI
145c_family_lang_mask = (CL_C | CL_CXX | CL_ObjC | CL_ObjCXX);
146
f4ff5a69
NB
147/* Defer option CODE with argument ARG. */
148static void
2f6e4e97 149defer_opt (enum opt_code code, const char *arg)
f4ff5a69 150{
f4ff5a69
NB
151 deferred_opts[deferred_count].code = code;
152 deferred_opts[deferred_count].arg = arg;
153 deferred_count++;
154}
155
7a9bf9a4 156/* Return language mask for option parsing. */
b86f6cd9 157unsigned int
7a9bf9a4 158c_common_option_lang_mask (void)
0b6f2917 159{
b86f6cd9 160 static const unsigned int lang_flags[] = {CL_C, CL_ObjC, CL_CXX, CL_ObjCXX};
37fa72e9 161
7a9bf9a4
JM
162 return lang_flags[c_language];
163}
164
18767f65
MLI
165/* Diagnostic finalizer for C/C++/Objective-C/Objective-C++. */
166static void
167c_diagnostic_finalizer (diagnostic_context *context,
478dd60d
DM
168 diagnostic_info *diagnostic,
169 diagnostic_t)
18767f65 170{
cc015f3a 171 diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind);
18767f65
MLI
172 /* By default print macro expansion contexts in the diagnostic
173 finalizer -- for tokens resulting from macro expansion. */
174 virt_loc_aware_diagnostic_finalizer (context, diagnostic);
175 pp_destroy_prefix (context->printer);
01e1dea3 176 pp_flush (context->printer);
18767f65
MLI
177}
178
d723bb7c 179/* Common default settings for diagnostics. */
7a9bf9a4 180void
d723bb7c 181c_common_diagnostics_set_defaults (diagnostic_context *context)
7a9bf9a4 182{
18767f65 183 diagnostic_finalizer (context) = c_diagnostic_finalizer;
7a9bf9a4
JM
184 context->opt_permissive = OPT_fpermissive;
185}
186
187/* Whether options from all C-family languages should be accepted
188 quietly. */
189static bool accept_all_c_family_options = false;
190
191/* Return whether to complain about a wrong-language option. */
192bool
193c_common_complain_wrong_lang_p (const struct cl_option *option)
194{
195 if (accept_all_c_family_options
196 && (option->flags & c_family_lang_mask))
197 return false;
198
199 return true;
200}
201
a75bfaa6
JM
202/* Initialize options structure OPTS. */
203void
204c_common_init_options_struct (struct gcc_options *opts)
205{
206 opts->x_flag_exceptions = c_dialect_cxx ();
207 opts->x_warn_pointer_arith = c_dialect_cxx ();
208 opts->x_warn_write_strings = c_dialect_cxx ();
209 opts->x_flag_warn_unused_result = true;
210
211 /* By default, C99-like requirements for complex multiply and divide. */
212 opts->x_flag_complex_method = 2;
213}
214
7a9bf9a4
JM
215/* Common initialization before calling option handlers. */
216void
217c_common_init_options (unsigned int decoded_options_count,
218 struct cl_decoded_option *decoded_options)
219{
220 unsigned int i;
221 struct cpp_callbacks *cb;
5f0f4a3b 222
88fa5555
DM
223 g_string_concat_db
224 = new (ggc_alloc <string_concat_db> ()) string_concat_db ();
225
37fa72e9 226 parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89,
5ffeb913 227 ident_hash, line_table);
148e4216 228 cb = cpp_get_callbacks (parse_in);
c24300ba 229 cb->diagnostic = c_cpp_diagnostic;
37fa72e9 230
18bdccaa 231 cpp_opts = cpp_get_options (parse_in);
b1822ccc 232 cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
37fa72e9 233 cpp_opts->objc = c_dialect_objc ();
78b8811a
HPN
234
235 /* Reset to avoid warnings on internal definitions. We set it just
236 before passing on command-line options to cpplib. */
237 cpp_opts->warn_dollars = 0;
238
7a9bf9a4 239 deferred_opts = XNEWVEC (struct deferred_opt, decoded_options_count);
33de9573 240
afd85c1a 241 if (c_language == clk_c)
33de9573 242 {
c76dc9c3
JM
243 /* The default for C is gnu17. */
244 set_std_c17 (false /* ISO */);
d73326ca 245
afd85c1a
RS
246 /* If preprocessing assembly language, accept any of the C-family
247 front end options since the driver may pass them through. */
7a9bf9a4
JM
248 for (i = 1; i < decoded_options_count; i++)
249 if (decoded_options[i].opt_index == OPT_lang_asm)
afd85c1a 250 {
7a9bf9a4 251 accept_all_c_family_options = true;
afd85c1a
RS
252 break;
253 }
33de9573 254 }
ebedc9a3 255
268be88c
BE
256 /* Set C++ standard to C++14 if not specified on the command line. */
257 if (c_dialect_cxx ())
258 set_std_cxx14 (/*ISO*/false);
259
ebedc9a3 260 global_dc->colorize_source_p = true;
0b6f2917
NB
261}
262
b20d9f0c 263/* Handle switch SCODE with argument ARG. VALUE is true, unless no-
5f20c657
JM
264 form of an -f or -W option was given. Returns false if the switch was
265 invalid, true if valid. Use HANDLERS in recursive handle_option calls. */
266bool
00abf86c 267c_common_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
a4d8c676
JM
268 int kind, location_t loc,
269 const struct cl_option_handlers *handlers)
0b6f2917 270{
2772ef3e
NB
271 const struct cl_option *option = &cl_options[scode];
272 enum opt_code code = (enum opt_code) scode;
5f20c657 273 bool result = true;
2772ef3e 274
69723be2
SB
275 /* Prevent resetting the language standard to a C dialect when the driver
276 has already determined that we're looking at assembler input. */
277 bool preprocessing_asm_p = (cpp_get_options (parse_in)->lang == CLK_ASM);
b8698a0f 278
fef3106c 279 switch (code)
0b6f2917 280 {
2772ef3e 281 default:
3734d960 282 if (cl_options[code].flags & c_family_lang_mask)
1f1d5130
MS
283 {
284 if ((option->flags & CL_TARGET)
285 && ! targetcm.handle_c_option (scode, arg, value))
5f20c657 286 result = false;
1f1d5130
MS
287 break;
288 }
5f20c657 289 result = false;
33de9573 290 break;
0b6f2917 291
fef3106c 292 case OPT__output_pch_:
17211ab5
GK
293 pch_file = arg;
294 break;
295
c1bad961
NB
296 case OPT_A:
297 defer_opt (code, arg);
298 break;
299
4b7091eb
NB
300 case OPT_C:
301 cpp_opts->discard_comments = 0;
302 break;
303
304 case OPT_CC:
305 cpp_opts->discard_comments = 0;
306 cpp_opts->discard_comments_in_macro_exp = 0;
307 break;
308
c1bad961
NB
309 case OPT_D:
310 defer_opt (code, arg);
311 break;
312
4b7091eb
NB
313 case OPT_H:
314 cpp_opts->print_include_names = 1;
315 break;
316
94d1613b
MS
317 case OPT_F:
318 TARGET_OPTF (xstrdup (arg));
319 break;
320
5793b276
NB
321 case OPT_I:
322 if (strcmp (arg, "-"))
b90c9338 323 add_path (xstrdup (arg), INC_BRACKET, 0, true);
5793b276
NB
324 else
325 {
326 if (quote_chain_split)
1fe61adf 327 error ("%<-I-%> specified twice");
5793b276
NB
328 quote_chain_split = true;
329 split_quote_chain ();
a3f9f006
ML
330 inform (input_location, "obsolete option %<-I-%> used, "
331 "please use %<-iquote%> instead");
5793b276
NB
332 }
333 break;
334
f4ff5a69
NB
335 case OPT_M:
336 case OPT_MM:
337 /* When doing dependencies with -M or -MM, suppress normal
338 preprocessed output, but still do -dM etc. as software
339 depends on this. Preprocessed output does occur if -MD, -MMD
340 or environment var dependency generation is used. */
341 cpp_opts->deps.style = (code == OPT_M ? DEPS_SYSTEM: DEPS_USER);
63973df3 342 flag_no_output = 1;
f4ff5a69
NB
343 break;
344
c878765b
JM
345 case OPT_MD:
346 case OPT_MMD:
347 cpp_opts->deps.style = (code == OPT_MD ? DEPS_SYSTEM: DEPS_USER);
74dc6a11 348 cpp_opts->deps.need_preprocessor_output = true;
f4ff5a69
NB
349 deps_file = arg;
350 break;
351
352 case OPT_MF:
353 deps_seen = true;
354 deps_file = arg;
355 break;
356
357 case OPT_MG:
358 deps_seen = true;
359 cpp_opts->deps.missing_files = true;
360 break;
361
362 case OPT_MP:
363 deps_seen = true;
364 cpp_opts->deps.phony_targets = true;
365 break;
366
367 case OPT_MQ:
368 case OPT_MT:
369 deps_seen = true;
370 defer_opt (code, arg);
371 break;
372
4b7091eb 373 case OPT_P:
63973df3 374 flag_no_line_commands = 1;
4b7091eb
NB
375 break;
376
c1bad961
NB
377 case OPT_U:
378 defer_opt (code, arg);
379 break;
380
0b6f2917 381 case OPT_Wall:
65d4f2cd 382 /* ??? Don't add new options here. Use LangEnabledBy in c.opt. */
18bdccaa 383
7b086b11 384 cpp_opts->warn_num_sign_change = value;
0b6f2917
NB
385 break;
386
0b6f2917
NB
387 case OPT_Wunknown_pragmas:
388 /* Set to greater than 1, so that even unknown pragmas in
2f6e4e97 389 system headers will be warned about. */
34a180a6 390 /* ??? There is no way to handle this automatically for now. */
7b086b11 391 warn_unknown_pragmas = value * 2;
0b6f2917
NB
392 break;
393
f749a36b 394 case OPT_ansi:
37fa72e9 395 if (!c_dialect_cxx ())
f749a36b
NB
396 set_std_c89 (false, true);
397 else
398 set_std_cxx98 (true);
399 break;
0b6f2917 400
4b7091eb
NB
401 case OPT_d:
402 handle_OPT_d (arg);
403 break;
404
62984918
JM
405 case OPT_Wabi_:
406 warn_abi = true;
407 if (value == 1)
408 {
409 warning (0, "%<-Wabi=1%> is not supported, using =2");
410 value = 2;
411 }
a75f1574 412 warn_abi_version = value;
62984918
JM
413 break;
414
5dc99c46
SB
415 case OPT_fcanonical_system_headers:
416 cpp_opts->canonical_system_headers = value;
417 break;
418
0b6f2917 419 case OPT_fcond_mismatch:
37fa72e9 420 if (!c_dialect_cxx ())
0b6f2917 421 {
7b086b11 422 flag_cond_mismatch = value;
0b6f2917
NB
423 break;
424 }
d4ee4d25 425 warning (0, "switch %qs is no longer supported", option->opt_text);
0b6f2917
NB
426 break;
427
0b6f2917 428 case OPT_fbuiltin_:
7b086b11 429 if (value)
5f20c657 430 result = false;
4b7091eb
NB
431 else
432 disable_builtin_function (arg);
0b6f2917
NB
433 break;
434
ccfc4c91 435 case OPT_fdirectives_only:
2710d6d7 436 cpp_opts->directives_only = value;
ccfc4c91
OW
437 break;
438
0b6f2917 439 case OPT_fdollars_in_identifiers:
7b086b11 440 cpp_opts->dollars_in_ident = value;
0b6f2917
NB
441 break;
442
7365279f
BK
443 case OPT_fmacro_prefix_map_:
444 add_macro_prefix_map (arg);
445 break;
446
0b6f2917 447 case OPT_ffreestanding:
7b086b11 448 value = !value;
191816a3 449 /* Fall through. */
0b6f2917 450 case OPT_fhosted:
7b086b11
NB
451 flag_hosted = value;
452 flag_no_builtin = !value;
0b6f2917
NB
453 break;
454
fef3106c 455 case OPT_fconstant_string_class_:
4b7091eb 456 constant_string_class_name = arg;
0b6f2917
NB
457 break;
458
af15a2fe
JM
459 case OPT_fextended_identifiers:
460 cpp_opts->extended_identifiers = value;
461 break;
462
18bdccaa 463 case OPT_foperator_names:
7b086b11 464 cpp_opts->operator_names = value;
18bdccaa
NB
465 break;
466
17211ab5 467 case OPT_fpch_deps:
7b086b11 468 cpp_opts->restore_pch_deps = value;
17211ab5
GK
469 break;
470
c0d578e6
GK
471 case OPT_fpch_preprocess:
472 flag_pch_preprocess = value;
473 break;
474
0b6f2917 475 case OPT_fpermissive:
0641fa97
RG
476 flag_permissive = value;
477 global_dc->permissive = value;
0b6f2917
NB
478 break;
479
18bdccaa 480 case OPT_fpreprocessed:
7b086b11 481 cpp_opts->preprocessed = value;
18bdccaa
NB
482 break;
483
847e697a
TT
484 case OPT_fdebug_cpp:
485 cpp_opts->debug = 1;
486 break;
487
92582b75
TT
488 case OPT_ftrack_macro_expansion:
489 if (value)
490 value = 2;
491 /* Fall Through. */
492
493 case OPT_ftrack_macro_expansion_:
494 if (arg && *arg != '\0')
495 cpp_opts->track_macro_expansion = value;
496 else
497 cpp_opts->track_macro_expansion = 2;
498 break;
499
0b6f2917 500 case OPT_frepo:
7b086b11
NB
501 flag_use_repository = value;
502 if (value)
0b6f2917
NB
503 flag_implicit_templates = 0;
504 break;
505
fef3106c 506 case OPT_ftabstop_:
18bdccaa 507 /* It is documented that we silently ignore silly values. */
7b086b11
NB
508 if (value >= 1 && value <= 100)
509 cpp_opts->tabstop = value;
18bdccaa
NB
510 break;
511
e6cc3a24
ZW
512 case OPT_fexec_charset_:
513 cpp_opts->narrow_charset = arg;
514 break;
515
516 case OPT_fwide_exec_charset_:
517 cpp_opts->wide_charset = arg;
518 break;
519
16dd5cfe
EC
520 case OPT_finput_charset_:
521 cpp_opts->input_charset = arg;
522 break;
523
fef3106c 524 case OPT_ftemplate_depth_:
7b086b11 525 max_tinst_depth = value;
0b6f2917
NB
526 break;
527
d7afec4b
ND
528 case OPT_fvisibility_inlines_hidden:
529 visibility_options.inlines_hidden = value;
530 break;
0b6f2917 531
39ef6592 532 case OPT_femit_struct_debug_baseonly:
299404a1 533 set_struct_debug_option (&global_options, loc, "base");
39ef6592
LC
534 break;
535
536 case OPT_femit_struct_debug_reduced:
299404a1 537 set_struct_debug_option (&global_options, loc,
69ccdddb 538 "dir:ord:sys,dir:gen:any,ind:base");
39ef6592
LC
539 break;
540
541 case OPT_femit_struct_debug_detailed_:
299404a1 542 set_struct_debug_option (&global_options, loc, arg);
39ef6592
LC
543 break;
544
a4a0016d
ESR
545 case OPT_fext_numeric_literals:
546 cpp_opts->ext_numeric_literals = value;
547 break;
548
5793b276 549 case OPT_idirafter:
b90c9338 550 add_path (xstrdup (arg), INC_AFTER, 0, true);
5793b276
NB
551 break;
552
255c10b1 553 case OPT_imacros:
23345bbb
NB
554 case OPT_include:
555 defer_opt (code, arg);
556 break;
557
2b6dd222
JM
558 case OPT_imultilib:
559 imultilib = arg;
560 break;
561
5793b276
NB
562 case OPT_iprefix:
563 iprefix = arg;
564 break;
565
4bed3787 566 case OPT_iquote:
b90c9338 567 add_path (xstrdup (arg), INC_QUOTE, 0, true);
4bed3787
MS
568 break;
569
5793b276
NB
570 case OPT_isysroot:
571 sysroot = arg;
572 break;
573
574 case OPT_isystem:
b90c9338 575 add_path (xstrdup (arg), INC_SYSTEM, 0, true);
5793b276
NB
576 break;
577
578 case OPT_iwithprefix:
b90c9338 579 add_prefixed_path (arg, INC_SYSTEM);
5793b276
NB
580 break;
581
582 case OPT_iwithprefixbefore:
b90c9338 583 add_prefixed_path (arg, INC_BRACKET);
5793b276
NB
584 break;
585
f749a36b
NB
586 case OPT_lang_asm:
587 cpp_set_lang (parse_in, CLK_ASM);
170ea7b9 588 cpp_opts->dollars_in_ident = false;
f749a36b
NB
589 break;
590
4b7091eb 591 case OPT_nostdinc:
5793b276 592 std_inc = false;
4b7091eb
NB
593 break;
594
fef3106c 595 case OPT_nostdinc__:
5793b276 596 std_cxx_inc = false;
4b7091eb
NB
597 break;
598
b4a93904 599 case OPT_o:
76c3e73e
NB
600 if (!out_fname)
601 out_fname = arg;
b4a93904 602 else
f75d3e11 603 error ("output filename specified twice");
b4a93904
NB
604 break;
605
0b6f2917
NB
606 case OPT_print_objc_runtime_info:
607 print_struct_values = 1;
608 break;
609
b4a93904
NB
610 case OPT_remap:
611 cpp_opts->remap = 1;
0b6f2917
NB
612 break;
613
fef3106c
NB
614 case OPT_std_c__98:
615 case OPT_std_gnu__98:
69723be2
SB
616 if (!preprocessing_asm_p)
617 set_std_cxx98 (code == OPT_std_c__98 /* ISO */);
0b6f2917
NB
618 break;
619
97e3ad20
JM
620 case OPT_std_c__11:
621 case OPT_std_gnu__11:
966541e3 622 if (!preprocessing_asm_p)
dcb466ec 623 set_std_cxx11 (code == OPT_std_c__11 /* ISO */);
966541e3
DG
624 break;
625
028aee17
JM
626 case OPT_std_c__14:
627 case OPT_std_gnu__14:
552b8185 628 if (!preprocessing_asm_p)
dcb466ec 629 set_std_cxx14 (code == OPT_std_c__14 /* ISO */);
552b8185
JM
630 break;
631
7b936140
JJ
632 case OPT_std_c__17:
633 case OPT_std_gnu__17:
da73100b 634 if (!preprocessing_asm_p)
7b936140 635 set_std_cxx17 (code == OPT_std_c__17 /* ISO */);
da73100b
JM
636 break;
637
026a79f7
AS
638 case OPT_std_c__2a:
639 case OPT_std_gnu__2a:
640 if (!preprocessing_asm_p)
641 set_std_cxx2a (code == OPT_std_c__2a /* ISO */);
642 break;
643
7e1542b9 644 case OPT_std_c90:
b4a93904 645 case OPT_std_iso9899_199409:
69723be2
SB
646 if (!preprocessing_asm_p)
647 set_std_c89 (code == OPT_std_iso9899_199409 /* c94 */, true /* ISO */);
f749a36b
NB
648 break;
649
7e1542b9 650 case OPT_std_gnu90:
69723be2
SB
651 if (!preprocessing_asm_p)
652 set_std_c89 (false /* c94 */, false /* ISO */);
0b6f2917
NB
653 break;
654
655 case OPT_std_c99:
69723be2
SB
656 if (!preprocessing_asm_p)
657 set_std_c99 (true /* ISO */);
0b6f2917
NB
658 break;
659
0b6f2917 660 case OPT_std_gnu99:
69723be2
SB
661 if (!preprocessing_asm_p)
662 set_std_c99 (false /* ISO */);
0b6f2917
NB
663 break;
664
48b0b196 665 case OPT_std_c11:
2778d766 666 if (!preprocessing_asm_p)
48b0b196 667 set_std_c11 (true /* ISO */);
2778d766
JM
668 break;
669
48b0b196 670 case OPT_std_gnu11:
2778d766 671 if (!preprocessing_asm_p)
48b0b196 672 set_std_c11 (false /* ISO */);
2778d766
JM
673 break;
674
c76dc9c3
JM
675 case OPT_std_c17:
676 if (!preprocessing_asm_p)
677 set_std_c17 (true /* ISO */);
678 break;
679
680 case OPT_std_gnu17:
681 if (!preprocessing_asm_p)
682 set_std_c17 (false /* ISO */);
683 break;
684
9f936c86
JM
685 case OPT_std_c2x:
686 if (!preprocessing_asm_p)
687 set_std_c2x (true /* ISO */);
688 break;
689
690 case OPT_std_gnu2x:
691 if (!preprocessing_asm_p)
692 set_std_c2x (false /* ISO */);
693 break;
694
4b7091eb
NB
695 case OPT_trigraphs:
696 cpp_opts->trigraphs = 1;
697 break;
698
699 case OPT_traditional_cpp:
700 cpp_opts->traditional = 1;
701 break;
702
4b7091eb 703 case OPT_v:
5793b276 704 verbose = true;
4b7091eb
NB
705 break;
706 }
0b6f2917 707
f2bc201f
MLI
708 switch (c_language)
709 {
710 case clk_c:
711 C_handle_option_auto (&global_options, &global_options_set,
712 scode, arg, value,
713 c_family_lang_mask, kind,
714 loc, handlers, global_dc);
715 break;
716
717 case clk_objc:
718 ObjC_handle_option_auto (&global_options, &global_options_set,
719 scode, arg, value,
720 c_family_lang_mask, kind,
721 loc, handlers, global_dc);
722 break;
723
724 case clk_cxx:
725 CXX_handle_option_auto (&global_options, &global_options_set,
726 scode, arg, value,
727 c_family_lang_mask, kind,
728 loc, handlers, global_dc);
729 break;
730
731 case clk_objcxx:
732 ObjCXX_handle_option_auto (&global_options, &global_options_set,
733 scode, arg, value,
734 c_family_lang_mask, kind,
735 loc, handlers, global_dc);
736 break;
737
738 default:
739 gcc_unreachable ();
740 }
43f9a13c
MLI
741
742 cpp_handle_option_auto (&global_options, scode, cpp_opts);
0b6f2917
NB
743 return result;
744}
745
acce4e77
JM
746/* Default implementation of TARGET_HANDLE_C_OPTION. */
747
748bool
749default_handle_c_option (size_t code ATTRIBUTE_UNUSED,
750 const char *arg ATTRIBUTE_UNUSED,
751 int value ATTRIBUTE_UNUSED)
752{
753 return false;
754}
755
0b6f2917
NB
756/* Post-switch processing. */
757bool
8e9ea4d7 758c_common_post_options (const char **pfilename)
0b6f2917 759{
8e9ea4d7
PB
760 struct cpp_callbacks *cb;
761
460bd0e3 762 /* Canonicalize the input and output filenames. */
d1bd0ded
GK
763 if (in_fnames == NULL)
764 {
5d038c4c 765 in_fnames = XNEWVEC (const char *, 1);
d1bd0ded
GK
766 in_fnames[0] = "";
767 }
768 else if (strcmp (in_fnames[0], "-") == 0)
cd445b54
ML
769 {
770 if (pch_file)
771 error ("cannot use %<-%> as input filename for a precompiled header");
772
773 in_fnames[0] = "";
774 }
460bd0e3 775
76c3e73e
NB
776 if (out_fname == NULL || !strcmp (out_fname, "-"))
777 out_fname = "";
778
cd79e210 779 if (cpp_opts->deps.style == DEPS_NONE)
76c3e73e
NB
780 check_deps_environment_vars ();
781
f4ff5a69 782 handle_deferred_opts ();
76c3e73e 783
f4ff5a69 784 sanitize_cpp_opts ();
460bd0e3 785
2b6dd222 786 register_include_chains (parse_in, sysroot, iprefix, imultilib,
37fa72e9 787 std_inc, std_cxx_inc && c_dialect_cxx (), verbose);
5793b276 788
c7b5e395
GK
789#ifdef C_COMMON_OVERRIDE_OPTIONS
790 /* Some machines may reject certain combinations of C
791 language-specific options. */
792 C_COMMON_OVERRIDE_OPTIONS;
793#endif
794
8ce94e44
JM
795 /* Excess precision other than "fast" requires front-end
796 support. */
797 if (c_dialect_cxx ())
798 {
75304c87 799 if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD)
a3f9f006 800 sorry ("%<-fexcess-precision=standard%> for C++");
8ce94e44
JM
801 flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
802 }
803 else if (flag_excess_precision_cmdline == EXCESS_PRECISION_DEFAULT)
804 flag_excess_precision_cmdline = (flag_iso
805 ? EXCESS_PRECISION_STANDARD
806 : EXCESS_PRECISION_FAST);
807
6dbe0958
JM
808 /* ISO C restricts floating-point expression contraction to within
809 source-language expressions (-ffp-contract=on, currently an alias
810 for -ffp-contract=off). */
811 if (flag_iso
812 && !c_dialect_cxx ()
813 && (global_options_set.x_flag_fp_contract_mode
75b107f5
IB
814 == (enum fp_contract_mode) 0)
815 && flag_unsafe_math_optimizations == 0)
6dbe0958
JM
816 flag_fp_contract_mode = FP_CONTRACT_OFF;
817
04f0fcf7
JG
818 /* If we are compiling C, and we are outside of a standards mode,
819 we can permit the new values from ISO/IEC TS 18661-3 for
820 FLT_EVAL_METHOD. Otherwise, we must restrict the possible values to
821 the set specified in ISO C99/C11. */
822 if (!flag_iso
823 && !c_dialect_cxx ()
824 && (global_options_set.x_flag_permitted_flt_eval_methods
825 == PERMITTED_FLT_EVAL_METHODS_DEFAULT))
826 flag_permitted_flt_eval_methods = PERMITTED_FLT_EVAL_METHODS_TS_18661;
827 else
828 flag_permitted_flt_eval_methods = PERMITTED_FLT_EVAL_METHODS_C11;
829
da1c7394
ILT
830 /* By default we use C99 inline semantics in GNU99 or C99 mode. C99
831 inline semantics are not supported in GNU89 or C89 mode. */
832 if (flag_gnu89_inline == -1)
833 flag_gnu89_inline = !flag_isoc99;
834 else if (!flag_gnu89_inline && !flag_isoc99)
a3f9f006 835 error ("%<-fno-gnu89-inline%> is only supported in GNU99 or C99 mode");
da1c7394 836
093c7153
RH
837 /* Default to ObjC sjlj exception handling if NeXT runtime. */
838 if (flag_objc_sjlj_exceptions < 0)
839 flag_objc_sjlj_exceptions = flag_next_runtime;
840 if (flag_objc_exceptions && !flag_objc_sjlj_exceptions)
841 flag_exceptions = 1;
842
b15458be
RB
843 /* If -ffreestanding, -fno-hosted or -fno-builtin then disable
844 pattern recognition. */
845 if (!global_options_set.x_flag_tree_loop_distribute_patterns
846 && flag_no_builtin)
847 flag_tree_loop_distribute_patterns = 0;
848
c1771a20 849 /* -Woverlength-strings is off by default, but is enabled by -Wpedantic.
89a42ac8
ZW
850 It is never enabled in C++, as the minimum limit is not normative
851 in that standard. */
34a180a6 852 if (c_dialect_cxx ())
89a42ac8
ZW
853 warn_overlength_strings = 0;
854
4003301d
MLI
855 /* Wmain is enabled by default in C++ but not in C. */
856 /* Wmain is disabled by default for -ffreestanding (!flag_hosted),
34a180a6
MLI
857 even if -Wall or -Wpedantic was given (warn_main will be 2 if set
858 by -Wall, 1 if set by -Wmain). */
4003301d
MLI
859 if (warn_main == -1)
860 warn_main = (c_dialect_cxx () && flag_hosted) ? 1 : 0;
861 else if (warn_main == 2)
862 warn_main = flag_hosted ? 1 : 0;
863
34a180a6
MLI
864 /* In C, -Wall and -Wc++-compat enable -Wenum-compare; if it has not
865 yet been set, it is disabled by default. In C++, it is enabled
866 by default. */
6866c6e8
ILT
867 if (warn_enum_compare == -1)
868 warn_enum_compare = c_dialect_cxx () ? 1 : 0;
869
bee6fa6d
AN
870 /* -Wpacked-bitfield-compat is on by default for the C languages. The
871 warning is issued in stor-layout.c which is not part of the front-end so
872 we need to selectively turn it on here. */
873 if (warn_packed_bitfield_compat == -1)
874 warn_packed_bitfield_compat = 1;
9b439fe1 875
0b6f2917
NB
876 /* Special format checking options don't work without -Wformat; warn if
877 they are used. */
44c21c7f
DD
878 if (!warn_format)
879 {
880 warning (OPT_Wformat_y2k,
a3f9f006 881 "%<-Wformat-y2k%> ignored without %<-Wformat%>");
44c21c7f 882 warning (OPT_Wformat_extra_args,
a3f9f006 883 "%<-Wformat-extra-args%> ignored without %<-Wformat%>");
44c21c7f 884 warning (OPT_Wformat_zero_length,
a3f9f006 885 "%<-Wformat-zero-length%> ignored without %<-Wformat%>");
44c21c7f 886 warning (OPT_Wformat_nonliteral,
a3f9f006 887 "%<-Wformat-nonliteral%> ignored without %<-Wformat%>");
ca178f85 888 warning (OPT_Wformat_contains_nul,
a3f9f006 889 "%<-Wformat-contains-nul%> ignored without %<-Wformat%>");
44c21c7f 890 warning (OPT_Wformat_security,
a3f9f006 891 "%<-Wformat-security%> ignored without %<-Wformat%>");
44c21c7f 892 }
0b6f2917 893
dc90f45b 894 /* -Wimplicit-function-declaration is enabled by default for C99. */
b8698a0f 895 if (warn_implicit_function_declaration == -1)
dc90f45b 896 warn_implicit_function_declaration = flag_isoc99;
c7463669 897
92574c7c
MP
898 /* -Wimplicit-int is enabled by default for C99. */
899 if (warn_implicit_int == -1)
900 warn_implicit_int = flag_isoc99;
901
451b5e48
MP
902 /* -Wshift-overflow is enabled by default in C99 and C++11 modes. */
903 if (warn_shift_overflow == -1)
904 warn_shift_overflow = cxx_dialect >= cxx11 || flag_isoc99;
905
0173bd2a
MP
906 /* -Wshift-negative-value is enabled by -Wextra in C99 and C++11 modes. */
907 if (warn_shift_negative_value == -1)
908 warn_shift_negative_value = (extra_warnings
909 && (cxx_dialect >= cxx11 || flag_isoc99));
910
a2c6e7f2
JJ
911 /* -Wregister is enabled by default in C++17. */
912 if (!global_options_set.x_warn_register)
7b936140 913 warn_register = cxx_dialect >= cxx17;
a2c6e7f2 914
1f26ac87
JM
915 /* Declone C++ 'structors if -Os. */
916 if (flag_declone_ctor_dtor == -1)
917 flag_declone_ctor_dtor = optimize_size;
918
62984918
JM
919 if (flag_abi_compat_version == 1)
920 {
921 warning (0, "%<-fabi-compat-version=1%> is not supported, using =2");
922 flag_abi_compat_version = 2;
923 }
34a7a230
JM
924
925 /* Change flag_abi_version to be the actual current ABI level, for the
926 benefit of c_cpp_builtins, and to make comparison simpler. */
927 const int latest_abi_version = 13;
928 /* Generate compatibility aliases for ABI v11 (7.1) by default. */
929 const int abi_compat_default = 11;
930
931#define clamp(X) if (X == 0 || X > latest_abi_version) X = latest_abi_version
932 clamp (flag_abi_version);
933 clamp (warn_abi_version);
934 clamp (flag_abi_compat_version);
935#undef clamp
936
937 /* Default -Wabi= or -fabi-compat-version= from each other. */
938 if (warn_abi_version == -1 && flag_abi_compat_version != -1)
939 warn_abi_version = flag_abi_compat_version;
940 else if (flag_abi_compat_version == -1 && warn_abi_version != -1)
941 flag_abi_compat_version = warn_abi_version;
942 else if (warn_abi_version == -1 && flag_abi_compat_version == -1)
62984918 943 {
34a7a230
JM
944 warn_abi_version = latest_abi_version;
945 if (flag_abi_version == latest_abi_version)
5cef3733 946 {
097f82ec 947 auto_diagnostic_group d;
93964ebd 948 if (warning (OPT_Wabi, "%<-Wabi%> won%'t warn about anything"))
5cef3733 949 {
a3f9f006 950 inform (input_location, "%<-Wabi%> warns about differences "
5cef3733
JM
951 "from the most up-to-date ABI, which is also used "
952 "by default");
a3f9f006 953 inform (input_location, "use e.g. %<-Wabi=11%> to warn about "
5cef3733
JM
954 "changes from GCC 7");
955 }
956 flag_abi_compat_version = abi_compat_default;
957 }
34a7a230
JM
958 else
959 flag_abi_compat_version = latest_abi_version;
62984918
JM
960 }
961
31f7f784
JM
962 /* By default, enable the new inheriting constructor semantics along with ABI
963 11. New and old should coexist fine, but it is a change in what
964 artificial symbols are generated. */
965 if (!global_options_set.x_flag_new_inheriting_ctors)
966 flag_new_inheriting_ctors = abi_version_at_least (11);
967
7b936140 968 /* For GCC 7, only enable DR150 resolution by default if -std=c++17. */
31bfc9b9 969 if (!global_options_set.x_flag_new_ttp)
7b936140 970 flag_new_ttp = (cxx_dialect >= cxx17);
31bfc9b9 971
604b2bfc 972 if (cxx_dialect >= cxx11)
25339f10
JM
973 {
974 /* If we're allowing C++0x constructs, don't warn about C++98
975 identifiers which are keywords in C++0x. */
765189ff 976 warn_cxx11_compat = 0;
edff0c06 977 cpp_opts->cpp_warn_cxx11_compat = 0;
25339f10
JM
978
979 if (warn_narrowing == -1)
980 warn_narrowing = 1;
dcb466ec
JJ
981
982 /* Unless -f{,no-}ext-numeric-literals has been used explicitly,
026a79f7 983 for -std=c++{11,14,17,2a} default to -fno-ext-numeric-literals. */
dcb466ec
JJ
984 if (flag_iso && !global_options_set.x_flag_ext_numeric_literals)
985 cpp_opts->ext_numeric_literals = 0;
25339f10
JM
986 }
987 else if (warn_narrowing == -1)
988 warn_narrowing = 0;
beeffe36 989
d0cf395a
JM
990 /* C++17 has stricter evaluation order requirements; let's use some of them
991 for earlier C++ as well, so chaining works as expected. */
4eb24e01 992 if (c_dialect_cxx ()
d0cf395a 993 && flag_strong_eval_order == -1)
7b936140 994 flag_strong_eval_order = (cxx_dialect >= cxx17 ? 2 : 1);
4eb24e01 995
20b06add
JM
996 /* Global sized deallocation is new in C++14. */
997 if (flag_sized_deallocation == -1)
998 flag_sized_deallocation = (cxx_dialect >= cxx14);
999
2d91f79d
TH
1000 /* char8_t support is new in C++2A. */
1001 if (flag_char8_t == -1)
1002 flag_char8_t = (cxx_dialect >= cxx2a);
1003
5af057d8
JM
1004 if (flag_extern_tls_init)
1005 {
a8b522b4
ML
1006 if (!TARGET_SUPPORTS_ALIASES || !SUPPORTS_WEAK)
1007 {
1008 /* Lazy TLS initialization for a variable in another TU requires
1009 alias and weak reference support. */
1010 if (flag_extern_tls_init > 0)
1011 sorry ("external TLS initialization functions not supported "
1012 "on this target");
1013
1014 flag_extern_tls_init = 0;
1015 }
1016 else
1017 flag_extern_tls_init = 1;
5af057d8
JM
1018 }
1019
b67b9225
DP
1020 /* Enable by default only for C++ and C++ with ObjC extensions. */
1021 if (warn_return_type == -1 && c_dialect_cxx ())
1022 warn_return_type = 1;
1b6fa695 1023
7c145456 1024 if (num_in_fnames > 1)
a9c697b8
MS
1025 error ("too many filenames given; type %<%s %s%> for usage",
1026 progname, "--help");
7c145456 1027
460bd0e3
NB
1028 if (flag_preprocess_only)
1029 {
63973df3
NB
1030 /* Open the output now. We must do so even if flag_no_output is
1031 on, because there may be other output than from the actual
1032 preprocessing (e.g. from -dM). */
1033 if (out_fname[0] == '\0')
1034 out_stream = stdout;
1035 else
1036 out_stream = fopen (out_fname, "w");
1037
1038 if (out_stream == NULL)
9d10c9a9 1039 {
40fecdd6 1040 fatal_error (input_location, "opening output file %s: %m", out_fname);
c366ade5 1041 return false;
9d10c9a9 1042 }
63973df3 1043
9d10c9a9 1044 init_pp_output (out_stream);
460bd0e3 1045 }
9d10c9a9
NB
1046 else
1047 {
1048 init_c_lex ();
237e9384
JJ
1049
1050 /* When writing a PCH file, avoid reading some other PCH file,
1051 because the default address space slot then can't be used
1052 for the output PCH file. */
1053 if (pch_file)
f6007d99
JJ
1054 {
1055 c_common_no_more_pch ();
1056 /* Only -g0 and -gdwarf* are supported with PCH, for other
1057 debug formats we warn here and refuse to load any PCH files. */
1058 if (write_symbols != NO_DEBUG && write_symbols != DWARF2_DEBUG)
1059 warning (OPT_Wdeprecated,
a9c697b8 1060 "the %qs debug format cannot be used with "
f6007d99
JJ
1061 "pre-compiled headers", debug_type_names[write_symbols]);
1062 }
1063 else if (write_symbols != NO_DEBUG && write_symbols != DWARF2_DEBUG)
237e9384 1064 c_common_no_more_pch ();
460bd0e3 1065
9d10c9a9 1066 /* Yuk. WTF is this? I do know ObjC relies on it somewhere. */
3c20847b 1067 input_location = UNKNOWN_LOCATION;
9d10c9a9 1068 }
63973df3 1069
8e9ea4d7
PB
1070 cb = cpp_get_callbacks (parse_in);
1071 cb->file_change = cb_file_change;
1072 cb->dir_change = cb_dir_change;
4169c321 1073 cpp_post_options (parse_in);
43f9a13c 1074 init_global_opts_from_cpp (&global_options, cpp_get_options (parse_in));
23345bbb 1075
3c20847b 1076 input_location = UNKNOWN_LOCATION;
4bfec483 1077
8e9ea4d7
PB
1078 *pfilename = this_input_filename
1079 = cpp_read_main_file (parse_in, in_fnames[0]);
540554f4 1080 /* Don't do any compilation or preprocessing if there is no input file. */
8e9ea4d7 1081 if (this_input_filename == NULL)
540554f4
JW
1082 {
1083 errorcount++;
1084 return false;
1085 }
8e9ea4d7 1086
8a4baa83 1087 if (flag_working_directory
3f75a254 1088 && flag_preprocess_only && !flag_no_line_commands)
8e9ea4d7
PB
1089 pp_dir_change (parse_in, get_src_pwd ());
1090
ba9b1f11
RG
1091 /* Disable LTO output when outputting a precompiled header. */
1092 if (pch_file && flag_lto)
1093 {
1094 flag_lto = 0;
1095 flag_generate_lto = 0;
1096 }
1097
4bfec483
NB
1098 return flag_preprocess_only;
1099}
1100
1101/* Front end initialization common to C, ObjC and C++. */
1102bool
2f6e4e97 1103c_common_init (void)
4bfec483 1104{
4bfec483
NB
1105 /* Set up preprocessor arithmetic. Must be done after call to
1106 c_common_nodes_and_builtins for type nodes to be good. */
1107 cpp_opts->precision = TYPE_PRECISION (intmax_type_node);
1108 cpp_opts->char_precision = TYPE_PRECISION (char_type_node);
1109 cpp_opts->int_precision = TYPE_PRECISION (integer_type_node);
1110 cpp_opts->wchar_precision = TYPE_PRECISION (wchar_type_node);
8df83eae 1111 cpp_opts->unsigned_wchar = TYPE_UNSIGNED (wchar_type_node);
e6cc3a24
ZW
1112 cpp_opts->bytes_big_endian = BYTES_BIG_ENDIAN;
1113
1114 /* This can't happen until after wchar_precision and bytes_big_endian
1115 are known. */
1116 cpp_init_iconv (parse_in);
460bd0e3 1117
3fd30b88 1118 if (version_flag)
8ca92d04
SB
1119 {
1120 int i;
1121 fputs ("Compiler executable checksum: ", stderr);
1122 for (i = 0; i < 16; i++)
1123 fprintf (stderr, "%02x", executable_checksum[i]);
1124 putc ('\n', stderr);
1125 }
3fd30b88 1126
a25a8f3b
JJ
1127 /* Has to wait until now so that cpplib has its hash table. */
1128 init_pragma ();
1129
9d10c9a9
NB
1130 if (flag_preprocess_only)
1131 {
c98cd5bf 1132 c_finish_options ();
8e9ea4d7 1133 preprocess_file (parse_in);
4bfec483 1134 return false;
9d10c9a9
NB
1135 }
1136
4bfec483 1137 return true;
76c3e73e
NB
1138}
1139
d1bd0ded
GK
1140/* Initialize the integrated preprocessor after debug output has been
1141 initialized; loop over each input file. */
23345bbb 1142void
b37421c6 1143c_common_parse_file (void)
23345bbb 1144{
9affb2c7
ZW
1145 unsigned int i;
1146
9affb2c7
ZW
1147 i = 0;
1148 for (;;)
1149 {
c98cd5bf 1150 c_finish_options ();
2a8a8d7b 1151 /* Open the dump file to use for the original dump output
f8a36c78
TJ
1152 here, to be used during parsing for the current file. */
1153 original_dump_file = dump_begin (TDI_original, &original_dump_flags);
9affb2c7
ZW
1154 pch_init ();
1155 push_file_scope ();
1156 c_parse_file ();
9affb2c7 1157 pop_file_scope ();
9e9945c5
DB
1158 /* And end the main input file, if the debug writer wants it */
1159 if (debug_hooks->start_end_main_source_file)
1160 (*debug_hooks->end_source_file) (0);
9affb2c7
ZW
1161 if (++i >= num_in_fnames)
1162 break;
1163 cpp_undef_all (parse_in);
97f6bd40 1164 cpp_clear_file_cache (parse_in);
9affb2c7
ZW
1165 this_input_filename
1166 = cpp_read_main_file (parse_in, in_fnames[i]);
f8a36c78
TJ
1167 if (original_dump_file)
1168 {
1169 dump_end (TDI_original, original_dump_file);
1170 original_dump_file = NULL;
1171 }
9affb2c7 1172 /* If an input file is missing, abandon further compilation.
c22cacf3 1173 cpplib has issued a diagnostic. */
9affb2c7
ZW
1174 if (!this_input_filename)
1175 break;
1176 }
d7438551
AH
1177
1178 c_parse_final_cleanups ();
23345bbb 1179}
f8a36c78
TJ
1180
1181/* Returns the appropriate dump file for PHASE to dump with FLAGS. */
2a8a8d7b 1182
f8a36c78 1183FILE *
1a817418 1184get_dump_info (int phase, dump_flags_t *flags)
f8a36c78 1185{
2a8a8d7b
NS
1186 gcc_assert (phase == TDI_original);
1187
1188 *flags = original_dump_flags;
1189 return original_dump_file;
f8a36c78 1190}
23345bbb 1191
76c3e73e
NB
1192/* Common finish hook for the C, ObjC and C++ front ends. */
1193void
2f6e4e97 1194c_common_finish (void)
76c3e73e
NB
1195{
1196 FILE *deps_stream = NULL;
1197
de7c2c6a
BK
1198 /* Note that we write the dependencies even if there are errors. This is
1199 useful for handling outdated generated headers that now trigger errors
1200 (for example, with #error) which would be resolved by re-generating
1201 them. In a sense, this complements -MG. */
1202 if (cpp_opts->deps.style != DEPS_NONE)
76c3e73e
NB
1203 {
1204 /* If -M or -MM was seen without -MF, default output to the
1205 output stream. */
f4ff5a69 1206 if (!deps_file)
76c3e73e 1207 deps_stream = out_stream;
e72c4afd
BK
1208 else if (deps_file[0] == '-' && deps_file[1] == '\0')
1209 deps_stream = stdout;
76c3e73e
NB
1210 else
1211 {
f4ff5a69 1212 deps_stream = fopen (deps_file, deps_append ? "a": "w");
76c3e73e 1213 if (!deps_stream)
40fecdd6
JM
1214 fatal_error (input_location, "opening dependency file %s: %m",
1215 deps_file);
76c3e73e
NB
1216 }
1217 }
1218
1219 /* For performance, avoid tearing down cpplib's internal structures
1220 with cpp_destroy (). */
148e4216 1221 cpp_finish (parse_in, deps_stream);
76c3e73e 1222
e72c4afd 1223 if (deps_stream && deps_stream != out_stream && deps_stream != stdout
76c3e73e 1224 && (ferror (deps_stream) || fclose (deps_stream)))
40fecdd6 1225 fatal_error (input_location, "closing dependency file %s: %m", deps_file);
76c3e73e
NB
1226
1227 if (out_stream && (ferror (out_stream) || fclose (out_stream)))
40fecdd6 1228 fatal_error (input_location, "when writing output to %s: %m", out_fname);
76c3e73e
NB
1229}
1230
76c3e73e
NB
1231/* Either of two environment variables can specify output of
1232 dependencies. Their value is either "OUTPUT_FILE" or "OUTPUT_FILE
1233 DEPS_TARGET", where OUTPUT_FILE is the file to write deps info to
1234 and DEPS_TARGET is the target to mention in the deps. They also
1235 result in dependency information being appended to the output file
182d89a3
NB
1236 rather than overwriting it, and like Sun's compiler
1237 SUNPRO_DEPENDENCIES suppresses the dependency on the main file. */
76c3e73e 1238static void
2f6e4e97 1239check_deps_environment_vars (void)
76c3e73e
NB
1240{
1241 char *spec;
1242
71f3e391 1243 spec = getenv ("DEPENDENCIES_OUTPUT");
76c3e73e 1244 if (spec)
f4ff5a69 1245 cpp_opts->deps.style = DEPS_USER;
76c3e73e
NB
1246 else
1247 {
71f3e391 1248 spec = getenv ("SUNPRO_DEPENDENCIES");
76c3e73e 1249 if (spec)
182d89a3
NB
1250 {
1251 cpp_opts->deps.style = DEPS_SYSTEM;
1252 cpp_opts->deps.ignore_main_file = true;
1253 }
76c3e73e
NB
1254 }
1255
1256 if (spec)
1257 {
1258 /* Find the space before the DEPS_TARGET, if there is one. */
1259 char *s = strchr (spec, ' ');
1260 if (s)
1261 {
1262 /* Let the caller perform MAKE quoting. */
f4ff5a69 1263 defer_opt (OPT_MT, s + 1);
76c3e73e
NB
1264 *s = '\0';
1265 }
1266
1267 /* Command line -MF overrides environment variables and default. */
f4ff5a69
NB
1268 if (!deps_file)
1269 deps_file = spec;
76c3e73e 1270
f4ff5a69 1271 deps_append = 1;
1b3c8f46 1272 deps_seen = true;
f4ff5a69
NB
1273 }
1274}
1275
1276/* Handle deferred command line switches. */
1277static void
2f6e4e97 1278handle_deferred_opts (void)
f4ff5a69 1279{
c6e83800
ZW
1280 /* Avoid allocating the deps buffer if we don't need it.
1281 (This flag may be true without there having been -MT or -MQ
1282 options, but we'll still need the deps buffer.) */
1283 if (!deps_seen)
1284 return;
1285
b744fc85 1286 struct mkdeps *deps = cpp_get_deps (parse_in);
f4ff5a69 1287
b744fc85 1288 for (size_t i = 0; i < deferred_count; i++)
f4ff5a69
NB
1289 {
1290 struct deferred_opt *opt = &deferred_opts[i];
1291
c1bad961 1292 if (opt->code == OPT_MT || opt->code == OPT_MQ)
c6e83800 1293 deps_add_target (deps, opt->arg, opt->code == OPT_MQ);
f4ff5a69 1294 }
f4ff5a69
NB
1295}
1296
1297/* These settings are appropriate for GCC, but not necessarily so for
1298 cpplib as a library. */
1299static void
2f6e4e97 1300sanitize_cpp_opts (void)
f4ff5a69
NB
1301{
1302 /* If we don't know what style of dependencies to output, complain
1303 if any other dependency switches have been given. */
1304 if (deps_seen && cpp_opts->deps.style == DEPS_NONE)
a3f9f006
ML
1305 error ("to generate dependencies you must specify either %<-M%> "
1306 "or %<-MM%>");
f4ff5a69
NB
1307
1308 /* -dM and dependencies suppress normal output; do it here so that
1309 the last -d[MDN] switch overrides earlier ones. */
63973df3
NB
1310 if (flag_dump_macros == 'M')
1311 flag_no_output = 1;
f4ff5a69 1312
ccfc4c91
OW
1313 /* By default, -fdirectives-only implies -dD. This allows subsequent phases
1314 to perform proper macro expansion. */
1315 if (cpp_opts->directives_only && !cpp_opts->preprocessed && !flag_dump_macros)
1316 flag_dump_macros = 'D';
1317
f4ff5a69
NB
1318 /* Disable -dD, -dN and -dI if normal output is suppressed. Allow
1319 -dM since at least glibc relies on -M -dM to work. */
6c6cfbfd 1320 /* Also, flag_no_output implies flag_no_line_commands, always. */
63973df3 1321 if (flag_no_output)
f4ff5a69 1322 {
63973df3
NB
1323 if (flag_dump_macros != 'M')
1324 flag_dump_macros = 0;
1325 flag_dump_includes = 0;
f9c65623 1326 flag_no_line_commands = 1;
76c3e73e 1327 }
4822e563 1328 else if (cpp_opts->deps.missing_files)
a3f9f006 1329 error ("%<-MG%> may only be used with %<-M%> or %<-MM%>");
f4ff5a69
NB
1330
1331 cpp_opts->unsigned_char = !flag_signed_char;
1332 cpp_opts->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;
1333
9c650d90 1334 /* Wlong-long is disabled by default. It is enabled by:
c1771a20 1335 [-Wpedantic | -Wtraditional] -std=[gnu|c]++98 ; or
2b71f4a4
MLI
1336 [-Wpedantic | -Wtraditional] -std=non-c99
1337
1338 Either -Wlong-long or -Wno-long-long override any other settings.
1339 ??? These conditions should be handled in c.opt. */
1340 if (warn_long_long == -1)
1341 {
1342 warn_long_long = ((pedantic || warn_traditional)
1343 && (c_dialect_cxx () ? cxx_dialect == cxx98 : !flag_isoc99));
1344 cpp_opts->cpp_warn_long_long = warn_long_long;
1345 }
b20d9f0c
AO
1346
1347 /* If we're generating preprocessor output, emit current directory
1348 if explicitly requested or if debugging information is enabled.
1349 ??? Maybe we should only do it for debugging formats that
1350 actually output the current directory? */
1351 if (flag_working_directory == -1)
1352 flag_working_directory = (debug_info_level != DINFO_LEVEL_NONE);
ccfc4c91 1353
70f6d5e1
JJ
1354 if (warn_implicit_fallthrough < 5)
1355 cpp_opts->cpp_warn_implicit_fallthrough = warn_implicit_fallthrough;
1356 else
1357 cpp_opts->cpp_warn_implicit_fallthrough = 0;
1358
ccfc4c91
OW
1359 if (cpp_opts->directives_only)
1360 {
34a180a6 1361 if (cpp_warn_unused_macros)
a3f9f006
ML
1362 error ("%<-fdirectives-only%> is incompatible "
1363 "with %<-Wunused-macros%>");
ccfc4c91 1364 if (cpp_opts->traditional)
a3f9f006 1365 error ("%<-fdirectives-only%> is incompatible with %<-traditional%>");
ccfc4c91 1366 }
f4ff5a69
NB
1367}
1368
5793b276
NB
1369/* Add include path with a prefix at the front of its name. */
1370static void
b90c9338 1371add_prefixed_path (const char *suffix, incpath_kind chain)
5793b276 1372{
52999738 1373 char *path;
5793b276 1374 const char *prefix;
52999738 1375 size_t prefix_len, suffix_len;
5793b276 1376
52999738
ZW
1377 suffix_len = strlen (suffix);
1378 prefix = iprefix ? iprefix : cpp_GCC_INCLUDE_DIR;
1379 prefix_len = iprefix ? strlen (iprefix) : cpp_GCC_INCLUDE_DIR_len;
1380
5d038c4c 1381 path = (char *) xmalloc (prefix_len + suffix_len + 1);
52999738
ZW
1382 memcpy (path, prefix, prefix_len);
1383 memcpy (path + prefix_len, suffix, suffix_len);
1384 path[prefix_len + suffix_len] = '\0';
1385
b02398bd 1386 add_path (path, chain, 0, false);
5793b276
NB
1387}
1388
8e9ea4d7
PB
1389/* Handle -D, -U, -A, -imacros, and the first -include. */
1390static void
c98cd5bf 1391c_finish_options (void)
255c10b1 1392{
255c10b1
NB
1393 if (!cpp_opts->preprocessed)
1394 {
ab5324fb
NS
1395 const line_map_ordinary *bltin_map
1396 = linemap_check_ordinary (linemap_add (line_table, LC_RENAME, 0,
1397 _("<built-in>"), 0));
1398 cb_file_change (parse_in, bltin_map);
c1bad961 1399
b35e0fa0 1400 /* Make sure all of the builtins about to be declared have
620e594b 1401 BUILTINS_LOCATION has their location_t. */
f3f6029d 1402 cpp_force_token_locations (parse_in, BUILTINS_LOCATION);
b35e0fa0
JJ
1403
1404 cpp_init_builtins (parse_in, flag_hosted);
1405 c_cpp_builtins (parse_in);
1406
78b8811a
HPN
1407 /* We're about to send user input to cpplib, so make it warn for
1408 things that we previously (when we sent it internal definitions)
1409 told it to not warn.
1410
1411 C99 permits implementation-defined characters in identifiers.
1412 The documented meaning of -std= is to turn off extensions that
1413 conflict with the specified standard, and since a strictly
1414 conforming program cannot contain a '$', we do not condition
1415 their acceptance on the -std= setting. */
e3339d0f 1416 cpp_opts->warn_dollars = (cpp_opts->cpp_pedantic && !cpp_opts->c99);
78b8811a 1417
ab5324fb
NS
1418 const line_map_ordinary *cmd_map
1419 = linemap_check_ordinary (linemap_add (line_table, LC_RENAME, 0,
1420 _("<command-line>"), 0));
1421 cb_file_change (parse_in, cmd_map);
112598f4 1422
ab5324fb
NS
1423 /* All command line defines must have the same location. */
1424 cpp_force_token_locations (parse_in, cmd_map->start_location);
1425 for (size_t i = 0; i < deferred_count; i++)
c1bad961
NB
1426 {
1427 struct deferred_opt *opt = &deferred_opts[i];
1428
1429 if (opt->code == OPT_D)
1430 cpp_define (parse_in, opt->arg);
1431 else if (opt->code == OPT_U)
1432 cpp_undef (parse_in, opt->arg);
1433 else if (opt->code == OPT_A)
1434 {
1435 if (opt->arg[0] == '-')
1436 cpp_unassert (parse_in, opt->arg + 1);
1437 else
1438 cpp_assert (parse_in, opt->arg);
1439 }
1440 }
255c10b1 1441
ab5324fb
NS
1442 cpp_stop_forcing_token_locations (parse_in);
1443 }
1444 else if (cpp_opts->directives_only)
1445 cpp_init_special_builtins (parse_in);
9d000e83 1446
ab5324fb
NS
1447 /* Start the main input file, if the debug writer wants it. */
1448 if (debug_hooks->start_end_main_source_file
1449 && !flag_preprocess_only)
1450 (*debug_hooks->start_source_file) (0, this_input_filename);
255c10b1 1451
ab5324fb
NS
1452 if (!cpp_opts->preprocessed)
1453 /* Handle -imacros after -D and -U. */
1454 for (size_t i = 0; i < deferred_count; i++)
1455 {
1456 struct deferred_opt *opt = &deferred_opts[i];
9d000e83 1457
ab5324fb
NS
1458 if (opt->code == OPT_imacros
1459 && cpp_push_include (parse_in, opt->arg))
1460 {
1461 /* Disable push_command_line_include callback for now. */
1462 include_cursor = deferred_count + 1;
1463 cpp_scan_nooutput (parse_in);
1464 }
1465 }
255c10b1 1466
e6ebd07b 1467 include_cursor = 0;
255c10b1
NB
1468 push_command_line_include ();
1469}
1470
23345bbb
NB
1471/* Give CPP the next file given by -include, if any. */
1472static void
2f6e4e97 1473push_command_line_include (void)
23345bbb 1474{
cdc94aca
MP
1475 /* This can happen if disabled by -imacros for example.
1476 Punt so that we don't set "<command-line>" as the filename for
1477 the header. */
1478 if (include_cursor > deferred_count)
1479 return;
1480
1efcb8c6
JM
1481 if (!done_preinclude)
1482 {
1483 done_preinclude = true;
1484 if (flag_hosted && std_inc && !cpp_opts->preprocessed)
1485 {
1486 const char *preinc = targetcm.c_preinclude ();
1487 if (preinc && cpp_push_default_include (parse_in, preinc))
1488 return;
1489 }
1490 }
1491
1492 pch_cpp_save_state ();
1493
23345bbb
NB
1494 while (include_cursor < deferred_count)
1495 {
1496 struct deferred_opt *opt = &deferred_opts[include_cursor++];
2f6e4e97 1497
3f75a254 1498 if (!cpp_opts->preprocessed && opt->code == OPT_include
31703a61 1499 && cpp_push_include (parse_in, opt->arg))
23345bbb
NB
1500 return;
1501 }
1502
1503 if (include_cursor == deferred_count)
1504 {
31703a61 1505 include_cursor++;
23345bbb 1506 /* -Wunused-macros should only warn about macros defined hereafter. */
34a180a6 1507 cpp_opts->warn_unused_macros = cpp_warn_unused_macros;
ab5324fb 1508 /* Restore the line map back to the main file. */
3f75a254 1509 if (!cpp_opts->preprocessed)
3e6da82b 1510 cpp_change_file (parse_in, LC_RENAME, this_input_filename);
8e9ea4d7
PB
1511
1512 /* Set this here so the client can change the option if it wishes,
1513 and after stacking the main file so we don't trace the main file. */
5ffeb913 1514 line_table->trace_includes = cpp_opts->print_include_names;
23345bbb
NB
1515 }
1516}
1517
1518/* File change callback. Has to handle -include files. */
1519static void
e18476eb 1520cb_file_change (cpp_reader * ARG_UNUSED (pfile),
0e50b624 1521 const line_map_ordinary *new_map)
23345bbb
NB
1522{
1523 if (flag_preprocess_only)
1524 pp_file_change (new_map);
1525 else
1526 fe_file_change (new_map);
1527
b826515a
BS
1528 if (new_map
1529 && (new_map->reason == LC_ENTER || new_map->reason == LC_RENAME))
1530 {
1531 /* Signal to plugins that a file is included. This could happen
1532 several times with the same file path, e.g. because of
1533 several '#include' or '#line' directives... */
1534 invoke_plugin_callbacks
1535 (PLUGIN_INCLUDE_FILE,
1536 const_cast<char*> (ORDINARY_MAP_FILE_NAME (new_map)));
1537 }
1538
31703a61 1539 if (new_map == 0 || (new_map->reason == LC_LEAVE && MAIN_FILE_P (new_map)))
1efcb8c6
JM
1540 {
1541 pch_cpp_save_state ();
1542 push_command_line_include ();
1543 }
23345bbb
NB
1544}
1545
8e9ea4d7 1546void
e18476eb 1547cb_dir_change (cpp_reader * ARG_UNUSED (pfile), const char *dir)
8e9ea4d7 1548{
3f75a254 1549 if (!set_src_pwd (dir))
d4ee4d25 1550 warning (0, "too late for # directive to set debug directory");
8e9ea4d7
PB
1551}
1552
f4ff5a69
NB
1553/* Set the C 89 standard (with 1994 amendments if C94, without GNU
1554 extensions if ISO). There is no concept of gnu94. */
1555static void
2f6e4e97 1556set_std_c89 (int c94, int iso)
f4ff5a69
NB
1557{
1558 cpp_set_lang (parse_in, c94 ? CLK_STDC94: iso ? CLK_STDC89: CLK_GNUC89);
1559 flag_iso = iso;
1560 flag_no_asm = iso;
1561 flag_no_gnu_keywords = iso;
1562 flag_no_nonansi_builtin = iso;
f4ff5a69
NB
1563 flag_isoc94 = c94;
1564 flag_isoc99 = 0;
48b0b196 1565 flag_isoc11 = 0;
9f936c86 1566 flag_isoc2x = 0;
dcc97066 1567 lang_hooks.name = "GNU C89";
76c3e73e
NB
1568}
1569
b4a93904
NB
1570/* Set the C 99 standard (without GNU extensions if ISO). */
1571static void
2f6e4e97 1572set_std_c99 (int iso)
b4a93904
NB
1573{
1574 cpp_set_lang (parse_in, iso ? CLK_STDC99: CLK_GNUC99);
1575 flag_no_asm = iso;
1576 flag_no_nonansi_builtin = iso;
b4a93904 1577 flag_iso = iso;
9f936c86 1578 flag_isoc2x = 0;
48b0b196 1579 flag_isoc11 = 0;
2778d766
JM
1580 flag_isoc99 = 1;
1581 flag_isoc94 = 1;
dcc97066 1582 lang_hooks.name = "GNU C99";
2778d766
JM
1583}
1584
48b0b196 1585/* Set the C 11 standard (without GNU extensions if ISO). */
2778d766 1586static void
48b0b196 1587set_std_c11 (int iso)
2778d766 1588{
48b0b196 1589 cpp_set_lang (parse_in, iso ? CLK_STDC11: CLK_GNUC11);
2778d766
JM
1590 flag_no_asm = iso;
1591 flag_no_nonansi_builtin = iso;
1592 flag_iso = iso;
9f936c86 1593 flag_isoc2x = 0;
48b0b196 1594 flag_isoc11 = 1;
b4a93904
NB
1595 flag_isoc99 = 1;
1596 flag_isoc94 = 1;
dcc97066 1597 lang_hooks.name = "GNU C11";
b4a93904
NB
1598}
1599
c76dc9c3
JM
1600/* Set the C 17 standard (without GNU extensions if ISO). */
1601static void
1602set_std_c17 (int iso)
1603{
1604 cpp_set_lang (parse_in, iso ? CLK_STDC17: CLK_GNUC17);
1605 flag_no_asm = iso;
1606 flag_no_nonansi_builtin = iso;
1607 flag_iso = iso;
9f936c86 1608 flag_isoc2x = 0;
c76dc9c3
JM
1609 flag_isoc11 = 1;
1610 flag_isoc99 = 1;
1611 flag_isoc94 = 1;
1612 lang_hooks.name = "GNU C17";
1613}
1614
9f936c86
JM
1615/* Set the C 2X standard (without GNU extensions if ISO). */
1616static void
1617set_std_c2x (int iso)
1618{
1619 cpp_set_lang (parse_in, iso ? CLK_STDC2X: CLK_GNUC2X);
1620 flag_no_asm = iso;
1621 flag_no_nonansi_builtin = iso;
1622 flag_iso = iso;
1623 flag_isoc2x = 1;
1624 flag_isoc11 = 1;
1625 flag_isoc99 = 1;
1626 flag_isoc94 = 1;
1627 lang_hooks.name = "GNU C2X";
1628}
1629
c76dc9c3 1630
f749a36b
NB
1631/* Set the C++ 98 standard (without GNU extensions if ISO). */
1632static void
2f6e4e97 1633set_std_cxx98 (int iso)
f749a36b
NB
1634{
1635 cpp_set_lang (parse_in, iso ? CLK_CXX98: CLK_GNUCXX);
1636 flag_no_gnu_keywords = iso;
1637 flag_no_nonansi_builtin = iso;
f749a36b 1638 flag_iso = iso;
268be88c
BE
1639 flag_isoc94 = 0;
1640 flag_isoc99 = 0;
c1ae8be5 1641 cxx_dialect = cxx98;
dcc97066 1642 lang_hooks.name = "GNU C++98";
f749a36b
NB
1643}
1644
97e3ad20 1645/* Set the C++ 2011 standard (without GNU extensions if ISO). */
966541e3 1646static void
97e3ad20 1647set_std_cxx11 (int iso)
966541e3 1648{
97e3ad20 1649 cpp_set_lang (parse_in, iso ? CLK_CXX11: CLK_GNUCXX11);
966541e3
DG
1650 flag_no_gnu_keywords = iso;
1651 flag_no_nonansi_builtin = iso;
1652 flag_iso = iso;
97e3ad20 1653 /* C++11 includes the C99 standard library. */
fcb21722
JM
1654 flag_isoc94 = 1;
1655 flag_isoc99 = 1;
97e3ad20 1656 cxx_dialect = cxx11;
dcc97066 1657 lang_hooks.name = "GNU C++11";
966541e3
DG
1658}
1659
7b936140 1660/* Set the C++ 2014 standard (without GNU extensions if ISO). */
552b8185 1661static void
e4276ba5 1662set_std_cxx14 (int iso)
552b8185 1663{
e4276ba5 1664 cpp_set_lang (parse_in, iso ? CLK_CXX14: CLK_GNUCXX14);
552b8185
JM
1665 flag_no_gnu_keywords = iso;
1666 flag_no_nonansi_builtin = iso;
1667 flag_iso = iso;
026a79f7 1668 /* C++14 includes the C99 standard library. */
552b8185
JM
1669 flag_isoc94 = 1;
1670 flag_isoc99 = 1;
e4276ba5 1671 cxx_dialect = cxx14;
dcc97066 1672 lang_hooks.name = "GNU C++14";
552b8185
JM
1673}
1674
7b936140 1675/* Set the C++ 2017 standard (without GNU extensions if ISO). */
da73100b 1676static void
7b936140 1677set_std_cxx17 (int iso)
da73100b 1678{
7b936140 1679 cpp_set_lang (parse_in, iso ? CLK_CXX17: CLK_GNUCXX17);
da73100b
JM
1680 flag_no_gnu_keywords = iso;
1681 flag_no_nonansi_builtin = iso;
1682 flag_iso = iso;
026a79f7 1683 /* C++17 includes the C11 standard library. */
da73100b
JM
1684 flag_isoc94 = 1;
1685 flag_isoc99 = 1;
e4276ba5 1686 flag_isoc11 = 1;
7b936140
JJ
1687 cxx_dialect = cxx17;
1688 lang_hooks.name = "GNU C++17";
da73100b
JM
1689}
1690
026a79f7
AS
1691/* Set the C++ 202a draft standard (without GNU extensions if ISO). */
1692static void
1693set_std_cxx2a (int iso)
1694{
1695 cpp_set_lang (parse_in, iso ? CLK_CXX2A: CLK_GNUCXX2A);
1696 flag_no_gnu_keywords = iso;
1697 flag_no_nonansi_builtin = iso;
1698 flag_iso = iso;
1699 /* C++17 includes the C11 standard library. */
1700 flag_isoc94 = 1;
1701 flag_isoc99 = 1;
1702 flag_isoc11 = 1;
1703 cxx_dialect = cxx2a;
1704 lang_hooks.name = "GNU C++17"; /* Pretend C++17 until standardization. */
1705}
1706
4b7091eb 1707/* Args to -d specify what to dump. Silently ignore
05713b80 1708 unrecognized options; they may be aimed at toplev.c. */
0b6f2917 1709static void
2f6e4e97 1710handle_OPT_d (const char *arg)
0b6f2917 1711{
4b7091eb
NB
1712 char c;
1713
1714 while ((c = *arg++) != '\0')
1715 switch (c)
1716 {
63973df3
NB
1717 case 'M': /* Dump macros only. */
1718 case 'N': /* Dump names. */
1719 case 'D': /* Dump definitions. */
93d45d9e 1720 case 'U': /* Dump used macros. */
63973df3 1721 flag_dump_macros = c;
4b7091eb
NB
1722 break;
1723
1724 case 'I':
63973df3 1725 flag_dump_includes = 1;
4b7091eb
NB
1726 break;
1727 }
0b6f2917 1728}