Branch data Line data Source code
1 : : /* C/ObjC/C++ command line option handling.
2 : : Copyright (C) 2002-2025 Free Software Foundation, Inc.
3 : : Contributed by Neil Booth.
4 : :
5 : : This file is part of GCC.
6 : :
7 : : GCC is free software; you can redistribute it and/or modify it under
8 : : the terms of the GNU General Public License as published by the Free
9 : : Software Foundation; either version 3, or (at your option) any later
10 : : version.
11 : :
12 : : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 : : WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 : : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 : : for more details.
16 : :
17 : : You should have received a copy of the GNU General Public License
18 : : along with GCC; see the file COPYING3. If not see
19 : : <http://www.gnu.org/licenses/>. */
20 : :
21 : : #define INCLUDE_VECTOR
22 : : #include "config.h"
23 : : #include "system.h"
24 : : #include "coretypes.h"
25 : : #include "tm.h"
26 : : #include "target.h"
27 : : #include "c-target.h"
28 : : #include "c-common.h"
29 : : #include "memmodel.h"
30 : : #include "tm_p.h" /* For C_COMMON_OVERRIDE_OPTIONS. */
31 : : #include "diagnostic.h"
32 : : #include "c-pragma.h"
33 : : #include "flags.h"
34 : : #include "toplev.h"
35 : : #include "langhooks.h"
36 : : #include "diagnostics/macro-unwinding.h" /* for virt_loc_aware_diagnostic_finalizer */
37 : : #include "intl.h"
38 : : #include "cppdefault.h"
39 : : #include "incpath.h"
40 : : #include "debug.h" /* For debug_hooks. */
41 : : #include "opts.h"
42 : : #include "plugin.h" /* For PLUGIN_INCLUDE_FILE event. */
43 : : #include "mkdeps.h"
44 : : #include "dumpfile.h"
45 : : #include "file-prefix-map.h" /* add_*_prefix_map() */
46 : : #include "context.h"
47 : : #include "diagnostics/text-sink.h"
48 : :
49 : : #ifndef DOLLARS_IN_IDENTIFIERS
50 : : # define DOLLARS_IN_IDENTIFIERS true
51 : : #endif
52 : :
53 : : #ifndef TARGET_SYSTEM_ROOT
54 : : # define TARGET_SYSTEM_ROOT NULL
55 : : #endif
56 : :
57 : : #ifndef TARGET_OPTF
58 : : #define TARGET_OPTF(ARG)
59 : : #endif
60 : :
61 : : /* CPP's options. */
62 : : cpp_options *cpp_opts;
63 : :
64 : : /* Input filename. */
65 : : static const char *this_input_filename;
66 : :
67 : : /* Filename and stream for preprocessed output. */
68 : : static const char *out_fname;
69 : : static FILE *out_stream;
70 : :
71 : : /* Append dependencies to deps_file. */
72 : : static bool deps_append;
73 : :
74 : : /* If dependency switches (-MF etc.) have been given. */
75 : : static bool deps_seen;
76 : :
77 : : /* If -v seen. */
78 : : static bool verbose;
79 : :
80 : : /* Dependency output file. */
81 : : static const char *deps_file;
82 : :
83 : : /* Structured dependency output file. */
84 : : static const char *fdeps_file;
85 : :
86 : : /* The prefix given by -iprefix, if any. */
87 : : static const char *iprefix;
88 : :
89 : : /* The multilib directory given by -imultilib, if any. */
90 : : static const char *imultilib;
91 : :
92 : : /* The system root, if any. Overridden by -isysroot. */
93 : : static const char *sysroot = TARGET_SYSTEM_ROOT;
94 : :
95 : : /* Zero disables all standard directories for headers. */
96 : : static bool std_inc = true;
97 : :
98 : : /* Zero disables the C++-specific standard directories for headers. */
99 : : static bool std_cxx_inc = true;
100 : :
101 : : /* If the quote chain has been split by -I-. */
102 : : static bool quote_chain_split;
103 : :
104 : : /* Number of deferred options. */
105 : : static size_t deferred_count;
106 : :
107 : : /* Number of deferred options scanned for -include. */
108 : : static size_t include_cursor;
109 : :
110 : : /* Whether any standard preincluded header has been preincluded. */
111 : : static bool done_preinclude;
112 : :
113 : : static void handle_OPT_d (const char *);
114 : : static void set_std_cxx98 (int);
115 : : static void set_std_cxx11 (int);
116 : : static void set_std_cxx14 (int);
117 : : static void set_std_cxx17 (int);
118 : : static void set_std_cxx20 (int);
119 : : static void set_std_cxx23 (int);
120 : : static void set_std_cxx26 (int);
121 : : static void set_std_c89 (int, int);
122 : : static void set_std_c99 (int);
123 : : static void set_std_c11 (int);
124 : : static void set_std_c17 (int);
125 : : static void set_std_c23 (int);
126 : : static void set_std_c2y (int);
127 : : static void check_deps_environment_vars (void);
128 : : static void handle_deferred_opts (void);
129 : : static void sanitize_cpp_opts (void);
130 : : static void add_prefixed_path (const char *, incpath_kind);
131 : : static void push_command_line_include (void);
132 : : static void cb_file_change (cpp_reader *, const line_map_ordinary *);
133 : : static void cb_dir_change (cpp_reader *, const char *);
134 : : static void c_finish_options (void);
135 : :
136 : : #ifndef STDC_0_IN_SYSTEM_HEADERS
137 : : #define STDC_0_IN_SYSTEM_HEADERS 0
138 : : #endif
139 : :
140 : : /* Holds switches parsed by c_common_handle_option (), but whose
141 : : handling is deferred to c_common_post_options (). */
142 : : static void defer_opt (enum opt_code, const char *);
143 : : static struct deferred_opt
144 : : {
145 : : enum opt_code code;
146 : : const char *arg;
147 : : } *deferred_opts;
148 : :
149 : :
150 : : extern const unsigned int
151 : : c_family_lang_mask = (CL_C | CL_CXX | CL_ObjC | CL_ObjCXX);
152 : :
153 : : /* Defer option CODE with argument ARG. */
154 : : static void
155 : 181206 : defer_opt (enum opt_code code, const char *arg)
156 : : {
157 : 181206 : deferred_opts[deferred_count].code = code;
158 : 181206 : deferred_opts[deferred_count].arg = arg;
159 : 181206 : deferred_count++;
160 : 181206 : }
161 : :
162 : : /* Return language mask for option parsing. */
163 : : unsigned int
164 : 6272201 : c_common_option_lang_mask (void)
165 : : {
166 : 6272201 : static const unsigned int lang_flags[] = {CL_C, CL_ObjC, CL_CXX, CL_ObjCXX};
167 : :
168 : 6272201 : return lang_flags[c_language];
169 : : }
170 : :
171 : : /* Diagnostic finalizer for C/C++/Objective-C/Objective-C++. */
172 : : static void
173 : 314603 : c_diagnostic_text_finalizer (diagnostics::text_sink &text_output,
174 : : const diagnostics::diagnostic_info *diagnostic,
175 : : enum diagnostics::kind)
176 : : {
177 : 314603 : pretty_printer *const pp = text_output.get_printer ();
178 : 314603 : char *saved_prefix = pp_take_prefix (pp);
179 : 314603 : pp_set_prefix (pp, text_output.build_indent_prefix (false));
180 : 314603 : pp_newline (pp);
181 : 314603 : diagnostic_show_locus (&text_output.get_context (),
182 : 314603 : text_output.get_source_printing_options (),
183 : 314603 : diagnostic->m_richloc, diagnostic->m_kind, pp);
184 : : /* By default print macro expansion contexts in the diagnostic
185 : : finalizer -- for tokens resulting from macro expansion. */
186 : 314603 : diagnostics::virt_loc_aware_text_finalizer (text_output, diagnostic);
187 : 314603 : pp_set_prefix (pp, saved_prefix);
188 : 314603 : pp_flush (pp);
189 : 314603 : }
190 : :
191 : : /* Common default settings for diagnostics. */
192 : : void
193 : 211321 : c_common_diagnostics_set_defaults (diagnostics::context *context)
194 : : {
195 : 211321 : diagnostics::text_finalizer (context) = c_diagnostic_text_finalizer;
196 : 211321 : context->set_permissive_option (OPT_fpermissive);
197 : 211321 : }
198 : :
199 : : /* Input charset configuration for diagnostics. */
200 : : static const char *
201 : 62468 : c_common_input_charset_cb (const char * /*filename*/)
202 : : {
203 : 62468 : const char *cs = cpp_opts->input_charset;
204 : 62468 : return cpp_input_conversion_is_trivial (cs) ? nullptr : cs;
205 : : }
206 : :
207 : : /* Whether options from all C-family languages should be accepted
208 : : quietly. */
209 : : static bool accept_all_c_family_options = false;
210 : :
211 : : /* Return whether to complain about a wrong-language option. */
212 : : bool
213 : 293 : c_common_complain_wrong_lang_p (const struct cl_option *option)
214 : : {
215 : 293 : if (accept_all_c_family_options
216 : 6 : && (option->flags & c_family_lang_mask))
217 : 6 : return false;
218 : :
219 : : return true;
220 : : }
221 : :
222 : : /* Initialize options structure OPTS. */
223 : : void
224 : 47697873 : c_common_init_options_struct (struct gcc_options *opts)
225 : : {
226 : 47697873 : opts->x_flag_exceptions = c_dialect_cxx ();
227 : 47697873 : opts->x_warn_pointer_arith = c_dialect_cxx ();
228 : 47697873 : opts->x_warn_write_strings = c_dialect_cxx ();
229 : 47697873 : opts->x_flag_warn_unused_result = true;
230 : :
231 : : /* By default, C99-like requirements for complex multiply and divide. */
232 : 47697873 : opts->x_flag_complex_method = 2;
233 : 47697873 : }
234 : :
235 : : /* Common initialization before calling option handlers. */
236 : : void
237 : 211321 : c_common_init_options (unsigned int decoded_options_count,
238 : : struct cl_decoded_option *decoded_options)
239 : : {
240 : 211321 : unsigned int i;
241 : 211321 : struct cpp_callbacks *cb;
242 : :
243 : 211321 : g_string_concat_db
244 : 211321 : = new (ggc_alloc <string_concat_db> ()) string_concat_db ();
245 : :
246 : 325362 : parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX : CLK_GNUC89,
247 : : ident_hash, line_table, ident_hash_extra);
248 : 211321 : cb = cpp_get_callbacks (parse_in);
249 : 211321 : cb->diagnostic = c_cpp_diagnostic;
250 : :
251 : 211321 : cpp_opts = cpp_get_options (parse_in);
252 : 211321 : cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
253 : 211321 : cpp_opts->objc = c_dialect_objc ();
254 : 211321 : cpp_opts->deps.modules = true;
255 : :
256 : : /* Reset to avoid warnings on internal definitions. We set it just
257 : : before passing on command-line options to cpplib. */
258 : 211321 : cpp_opts->warn_dollars = 0;
259 : :
260 : 211321 : deferred_opts = XNEWVEC (struct deferred_opt, decoded_options_count);
261 : :
262 : 211321 : if (c_language == clk_c)
263 : : {
264 : : /* The default for C is gnu23. */
265 : 114041 : set_std_c23 (false /* ISO */);
266 : :
267 : : /* If preprocessing assembly language, accept any of the C-family
268 : : front end options since the driver may pass them through. */
269 : 2904414 : for (i = 1; i < decoded_options_count; i++)
270 : 2677312 : if (decoded_options[i].opt_index == OPT_lang_asm)
271 : : {
272 : 980 : accept_all_c_family_options = true;
273 : 980 : break;
274 : : }
275 : : }
276 : :
277 : : /* Set C++ standard to C++20 if not specified on the command line. */
278 : 211321 : if (c_dialect_cxx ())
279 : 97280 : set_std_cxx20 (/*ISO*/false);
280 : :
281 : 211321 : global_dc->get_source_printing_options ().colorize_source_p = true;
282 : 211321 : }
283 : :
284 : : /* Handle switch SCODE with argument ARG. VALUE is true, unless no-
285 : : form of an -f or -W option was given. Returns false if the switch was
286 : : invalid, true if valid. Use HANDLERS in recursive handle_option calls. */
287 : : bool
288 : 3336790 : c_common_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
289 : : int kind, location_t loc,
290 : : const struct cl_option_handlers *handlers)
291 : : {
292 : 3336790 : const struct cl_option *option = &cl_options[scode];
293 : 3336790 : enum opt_code code = (enum opt_code) scode;
294 : 3336790 : bool result = true;
295 : :
296 : : /* Prevent resetting the language standard to a C dialect when the driver
297 : : has already determined that we're looking at assembler input. */
298 : 3336790 : bool preprocessing_asm_p = (cpp_get_options (parse_in)->lang == CLK_ASM);
299 : :
300 : 3336790 : switch (code)
301 : : {
302 : 1438390 : default:
303 : 1438390 : if (cl_options[code].flags & c_family_lang_mask)
304 : : {
305 : 1438390 : if ((option->flags & CL_TARGET)
306 : 1438390 : && ! targetcm.handle_c_option (scode, arg, value))
307 : : result = false;
308 : : break;
309 : : }
310 : : result = false;
311 : : break;
312 : :
313 : 464 : case OPT__output_pch:
314 : 464 : pch_file = arg;
315 : 464 : break;
316 : :
317 : 10 : case OPT_A:
318 : 10 : defer_opt (code, arg);
319 : 10 : break;
320 : :
321 : 13 : case OPT_C:
322 : 13 : cpp_opts->discard_comments = 0;
323 : 13 : break;
324 : :
325 : 11 : case OPT_CC:
326 : 11 : cpp_opts->discard_comments = 0;
327 : 11 : cpp_opts->discard_comments_in_macro_exp = 0;
328 : 11 : break;
329 : :
330 : 165064 : case OPT_D:
331 : 165064 : defer_opt (code, arg);
332 : 165064 : break;
333 : :
334 : 25 : case OPT_H:
335 : 25 : cpp_opts->print_include_names = 1;
336 : 25 : break;
337 : :
338 : : case OPT_F:
339 : : TARGET_OPTF (xstrdup (arg));
340 : : break;
341 : :
342 : 551025 : case OPT_I:
343 : 551025 : if (strcmp (arg, "-"))
344 : 551025 : add_path (xstrdup (arg), INC_BRACKET, 0, true);
345 : : else
346 : : {
347 : 0 : if (quote_chain_split)
348 : 0 : error ("%<-I-%> specified twice");
349 : 0 : quote_chain_split = true;
350 : 0 : split_quote_chain ();
351 : 0 : inform (input_location, "obsolete option %<-I-%> used, "
352 : : "please use %<-iquote%> instead");
353 : : }
354 : : break;
355 : :
356 : 25 : case OPT_M:
357 : 25 : case OPT_MM:
358 : : /* When doing dependencies with -M or -MM, suppress normal
359 : : preprocessed output, but still do -dM etc. as software
360 : : depends on this. Preprocessed output does occur if -MD, -MMD
361 : : or environment var dependency generation is used. */
362 : 25 : cpp_opts->deps.style = (code == OPT_M ? DEPS_SYSTEM : DEPS_USER);
363 : 25 : flag_no_output = 1;
364 : 25 : break;
365 : :
366 : 5840 : case OPT_MD:
367 : 5840 : case OPT_MMD:
368 : 5840 : cpp_opts->deps.style = (code == OPT_MD ? DEPS_SYSTEM : DEPS_USER);
369 : 5840 : cpp_opts->deps.need_preprocessor_output = true;
370 : 5840 : deps_file = arg;
371 : 5840 : break;
372 : :
373 : 51 : case OPT_fdeps_format_:
374 : : /* https://wg21.link/p1689r5 */
375 : 51 : if (!strcmp (arg, "p1689r5"))
376 : 48 : cpp_opts->deps.fdeps_format = FDEPS_FMT_P1689R5;
377 : : else
378 : 3 : error ("%<-fdeps-format=%> unknown format %qs", arg);
379 : : break;
380 : :
381 : 63 : case OPT_fdeps_file_:
382 : 63 : deps_seen = true;
383 : 63 : fdeps_file = arg;
384 : 63 : break;
385 : :
386 : 63 : case OPT_fdeps_target_:
387 : 63 : deps_seen = true;
388 : 63 : defer_opt (code, arg);
389 : 63 : break;
390 : :
391 : 5784 : case OPT_MF:
392 : 5784 : deps_seen = true;
393 : 5784 : deps_file = arg;
394 : 5784 : break;
395 : :
396 : 3 : case OPT_MG:
397 : 3 : deps_seen = true;
398 : 3 : cpp_opts->deps.missing_files = true;
399 : 3 : break;
400 : :
401 : 5769 : case OPT_MP:
402 : 5769 : deps_seen = true;
403 : 5769 : cpp_opts->deps.phony_targets = true;
404 : 5769 : break;
405 : :
406 : 0 : case OPT_Mmodules:
407 : : /* Do not set deps_seen, so the user can unconditionally turn
408 : : this on or off. */
409 : 0 : cpp_opts->deps.modules = true;
410 : 0 : break;
411 : :
412 : 3 : case OPT_Mno_modules:
413 : : /* Do not set deps_seen, so the user can unconditionally turn
414 : : this on or off. */
415 : 3 : cpp_opts->deps.modules = false;
416 : 3 : break;
417 : :
418 : 5836 : case OPT_MQ:
419 : 5836 : case OPT_MT:
420 : 5836 : deps_seen = true;
421 : 5836 : defer_opt (code, arg);
422 : 5836 : break;
423 : :
424 : 43 : case OPT_P:
425 : 43 : flag_no_line_commands = 1;
426 : 43 : break;
427 : :
428 : 61 : case OPT_U:
429 : 61 : defer_opt (code, arg);
430 : 61 : break;
431 : :
432 : 10893 : case OPT_Wall:
433 : : /* ??? Don't add new options here. Use LangEnabledBy in c.opt. */
434 : :
435 : 10893 : cpp_opts->warn_num_sign_change = value;
436 : 10893 : break;
437 : :
438 : 10979 : case OPT_Wunknown_pragmas:
439 : : /* Set to greater than 1, so that even unknown pragmas in
440 : : system headers will be warned about. */
441 : : /* ??? There is no way to handle this automatically for now. */
442 : 10979 : warn_unknown_pragmas = value * 2;
443 : 10979 : break;
444 : :
445 : 3950 : case OPT_ansi:
446 : 3950 : if (!c_dialect_cxx ())
447 : 3804 : set_std_c89 (false, true);
448 : : else
449 : 146 : set_std_cxx98 (true);
450 : : break;
451 : :
452 : 1637 : case OPT_d:
453 : 1637 : handle_OPT_d (arg);
454 : 1637 : break;
455 : :
456 : 13437 : case OPT_Wabi_:
457 : 13437 : warn_abi = true;
458 : 13437 : if (value == 1)
459 : : {
460 : 0 : warning (0, "%<-Wabi=1%> is not supported, using =2");
461 : 0 : value = 2;
462 : : }
463 : 13437 : warn_abi_version = value;
464 : 13437 : break;
465 : :
466 : 18 : case OPT_fcanonical_system_headers:
467 : 18 : cpp_opts->canonical_system_headers = value;
468 : 18 : break;
469 : :
470 : 12 : case OPT_fcond_mismatch:
471 : 12 : if (!c_dialect_cxx ())
472 : : {
473 : 12 : flag_cond_mismatch = value;
474 : 12 : break;
475 : : }
476 : 0 : warning (0, "switch %qs is no longer supported", option->opt_text);
477 : 0 : break;
478 : :
479 : 308 : case OPT_fbuiltin_:
480 : 308 : if (value)
481 : : result = false;
482 : : else
483 : 308 : disable_builtin_function (arg);
484 : : break;
485 : :
486 : 1090 : case OPT_fdirectives_only:
487 : 1090 : cpp_opts->directives_only = value;
488 : 1090 : break;
489 : :
490 : 7 : case OPT_fdollars_in_identifiers:
491 : 7 : cpp_opts->dollars_in_ident = value;
492 : 7 : break;
493 : :
494 : 8 : case OPT_fmacro_prefix_map_:
495 : 8 : add_macro_prefix_map (arg);
496 : 8 : break;
497 : :
498 : 711 : case OPT_ffreestanding:
499 : 711 : value = !value;
500 : : /* Fall through. */
501 : 719 : case OPT_fhosted:
502 : 719 : flag_hosted = value;
503 : 719 : flag_no_builtin = !value;
504 : 719 : break;
505 : :
506 : 0 : case OPT_fconstant_string_class_:
507 : 0 : constant_string_class_name = arg;
508 : 0 : break;
509 : :
510 : 0 : case OPT_fextended_identifiers:
511 : 0 : cpp_opts->extended_identifiers = value;
512 : 0 : break;
513 : :
514 : 4 : case OPT_fmax_include_depth_:
515 : 4 : cpp_opts->max_include_depth = value;
516 : 4 : break;
517 : :
518 : 4 : case OPT_foperator_names:
519 : 4 : cpp_opts->operator_names = value;
520 : 4 : break;
521 : :
522 : 0 : case OPT_fpch_deps:
523 : 0 : cpp_opts->restore_pch_deps = value;
524 : 0 : break;
525 : :
526 : 475 : case OPT_fpch_preprocess:
527 : 475 : flag_pch_preprocess = value;
528 : 475 : break;
529 : :
530 : 1151 : case OPT_fpermissive:
531 : 1151 : flag_permissive = value;
532 : 1151 : global_dc->m_permissive = value;
533 : 1151 : break;
534 : :
535 : 527 : case OPT_fpreprocessed:
536 : 527 : cpp_opts->preprocessed = value;
537 : 527 : break;
538 : :
539 : 2 : case OPT_fdebug_cpp:
540 : 2 : cpp_opts->debug = value;
541 : 2 : break;
542 : :
543 : 1 : case OPT_ftrack_macro_expansion:
544 : 1 : if (value)
545 : 0 : value = 2;
546 : : /* Fall Through. */
547 : :
548 : 483 : case OPT_ftrack_macro_expansion_:
549 : 483 : if (arg && *arg != '\0')
550 : 482 : cpp_opts->track_macro_expansion = value;
551 : : else
552 : 1 : cpp_opts->track_macro_expansion = 2;
553 : : break;
554 : :
555 : 86 : case OPT_fexec_charset_:
556 : 86 : cpp_opts->narrow_charset = arg;
557 : 86 : break;
558 : :
559 : 2 : case OPT_fwide_exec_charset_:
560 : 2 : cpp_opts->wide_charset = arg;
561 : 2 : break;
562 : :
563 : 93 : case OPT_finput_charset_:
564 : 93 : cpp_opts->input_charset = arg;
565 : 93 : cpp_opts->cpp_input_charset_explicit = 1;
566 : 93 : break;
567 : :
568 : 29 : case OPT_ftemplate_depth_:
569 : 29 : max_tinst_depth = value;
570 : 29 : break;
571 : :
572 : 21 : case OPT_fvisibility_inlines_hidden:
573 : 21 : visibility_options.inlines_hidden = value;
574 : 21 : break;
575 : :
576 : 22 : case OPT_femit_struct_debug_baseonly:
577 : 22 : set_struct_debug_option (&global_options, loc, "base");
578 : 22 : break;
579 : :
580 : 8 : case OPT_femit_struct_debug_reduced:
581 : 8 : set_struct_debug_option (&global_options, loc,
582 : : "dir:ord:sys,dir:gen:any,ind:base");
583 : 8 : break;
584 : :
585 : 12 : case OPT_femit_struct_debug_detailed_:
586 : 12 : set_struct_debug_option (&global_options, loc, arg);
587 : 12 : break;
588 : :
589 : 17 : case OPT_fext_numeric_literals:
590 : 17 : cpp_opts->ext_numeric_literals = value;
591 : 17 : break;
592 : :
593 : 4 : case OPT_idirafter:
594 : 4 : add_path (xstrdup (arg), INC_AFTER, 0, true);
595 : 4 : break;
596 : :
597 : 10172 : case OPT_imacros:
598 : 10172 : case OPT_include:
599 : 10172 : defer_opt (code, arg);
600 : 10172 : break;
601 : :
602 : 5336 : case OPT_imultilib:
603 : 5336 : imultilib = arg;
604 : 5336 : break;
605 : :
606 : 207986 : case OPT_iprefix:
607 : 207986 : iprefix = arg;
608 : 207986 : break;
609 : :
610 : 2866 : case OPT_iquote:
611 : 2866 : add_path (xstrdup (arg), INC_QUOTE, 0, true);
612 : 2866 : break;
613 : :
614 : 0 : case OPT_isysroot:
615 : 0 : sysroot = arg;
616 : 0 : break;
617 : :
618 : 467938 : case OPT_isystem:
619 : 467938 : add_path (xstrdup (arg), INC_SYSTEM, 0, true);
620 : 467938 : break;
621 : :
622 : 0 : case OPT_iwithprefix:
623 : 0 : add_prefixed_path (arg, INC_SYSTEM);
624 : 0 : break;
625 : :
626 : 0 : case OPT_iwithprefixbefore:
627 : 0 : add_prefixed_path (arg, INC_BRACKET);
628 : 0 : break;
629 : :
630 : 81 : case OPT__embed_dir_:
631 : 81 : add_path (xstrdup (arg), INC_EMBED, 0, true);
632 : 81 : break;
633 : :
634 : 980 : case OPT_lang_asm:
635 : 980 : cpp_set_lang (parse_in, CLK_ASM);
636 : 980 : cpp_opts->dollars_in_ident = false;
637 : 980 : break;
638 : :
639 : 60 : case OPT_nostdinc:
640 : 60 : std_inc = false;
641 : 60 : break;
642 : :
643 : 109949 : case OPT_nostdinc__:
644 : 109949 : std_cxx_inc = false;
645 : 109949 : break;
646 : :
647 : 210578 : case OPT_o:
648 : 210578 : if (!out_fname)
649 : 210578 : out_fname = arg;
650 : : else
651 : 0 : error ("output filename specified twice");
652 : : break;
653 : :
654 : 0 : case OPT_print_objc_runtime_info:
655 : 0 : print_struct_values = 1;
656 : 0 : break;
657 : :
658 : 2 : case OPT_remap:
659 : 2 : cpp_opts->remap = 1;
660 : 2 : break;
661 : :
662 : 14001 : case OPT_std_c__98:
663 : 14001 : case OPT_std_gnu__98:
664 : 14001 : if (!preprocessing_asm_p)
665 : 14001 : set_std_cxx98 (code == OPT_std_c__98 /* ISO */);
666 : : break;
667 : :
668 : 5616 : case OPT_std_c__11:
669 : 5616 : case OPT_std_gnu__11:
670 : 5616 : if (!preprocessing_asm_p)
671 : 5616 : set_std_cxx11 (code == OPT_std_c__11 /* ISO */);
672 : : break;
673 : :
674 : 1278 : case OPT_std_c__14:
675 : 1278 : case OPT_std_gnu__14:
676 : 1278 : if (!preprocessing_asm_p)
677 : 1278 : set_std_cxx14 (code == OPT_std_c__14 /* ISO */);
678 : : break;
679 : :
680 : 11960 : case OPT_std_c__17:
681 : 11960 : case OPT_std_gnu__17:
682 : 11960 : if (!preprocessing_asm_p)
683 : 11960 : set_std_cxx17 (code == OPT_std_c__17 /* ISO */);
684 : : break;
685 : :
686 : 23997 : case OPT_std_c__20:
687 : 23997 : case OPT_std_gnu__20:
688 : 23997 : if (!preprocessing_asm_p)
689 : 23997 : set_std_cxx20 (code == OPT_std_c__20 /* ISO */);
690 : : break;
691 : :
692 : 1963 : case OPT_std_c__23:
693 : 1963 : case OPT_std_gnu__23:
694 : 1963 : if (!preprocessing_asm_p)
695 : 1963 : set_std_cxx23 (code == OPT_std_c__23 /* ISO */);
696 : : break;
697 : :
698 : 23816 : case OPT_std_c__26:
699 : 23816 : case OPT_std_gnu__26:
700 : 23816 : if (!preprocessing_asm_p)
701 : 23816 : set_std_cxx26 (code == OPT_std_c__26 /* ISO */);
702 : : break;
703 : :
704 : 191 : case OPT_std_c90:
705 : 191 : case OPT_std_iso9899_199409:
706 : 191 : if (!preprocessing_asm_p)
707 : 191 : set_std_c89 (code == OPT_std_iso9899_199409 /* c94 */, true /* ISO */);
708 : : break;
709 : :
710 : 2952 : case OPT_std_gnu90:
711 : 2952 : if (!preprocessing_asm_p)
712 : 2952 : set_std_c89 (false /* c94 */, false /* ISO */);
713 : : break;
714 : :
715 : 573 : case OPT_std_c99:
716 : 573 : if (!preprocessing_asm_p)
717 : 572 : set_std_c99 (true /* ISO */);
718 : : break;
719 : :
720 : 616 : case OPT_std_gnu99:
721 : 616 : if (!preprocessing_asm_p)
722 : 616 : set_std_c99 (false /* ISO */);
723 : : break;
724 : :
725 : 512 : case OPT_std_c11:
726 : 512 : if (!preprocessing_asm_p)
727 : 512 : set_std_c11 (true /* ISO */);
728 : : break;
729 : :
730 : 3694 : case OPT_std_gnu11:
731 : 3694 : if (!preprocessing_asm_p)
732 : 3694 : set_std_c11 (false /* ISO */);
733 : : break;
734 : :
735 : 42 : case OPT_std_c17:
736 : 42 : if (!preprocessing_asm_p)
737 : 42 : set_std_c17 (true /* ISO */);
738 : : break;
739 : :
740 : 784 : case OPT_std_gnu17:
741 : 784 : if (!preprocessing_asm_p)
742 : 784 : set_std_c17 (false /* ISO */);
743 : : break;
744 : :
745 : 853 : case OPT_std_c23:
746 : 853 : if (!preprocessing_asm_p)
747 : 853 : set_std_c23 (true /* ISO */);
748 : : break;
749 : :
750 : 202 : case OPT_std_gnu23:
751 : 202 : if (!preprocessing_asm_p)
752 : 202 : set_std_c23 (false /* ISO */);
753 : : break;
754 : :
755 : 177 : case OPT_std_c2y:
756 : 177 : if (!preprocessing_asm_p)
757 : 177 : set_std_c2y (true /* ISO */);
758 : : break;
759 : :
760 : 11 : case OPT_std_gnu2y:
761 : 11 : if (!preprocessing_asm_p)
762 : 11 : set_std_c2y (false /* ISO */);
763 : : break;
764 : :
765 : 20 : case OPT_trigraphs:
766 : 20 : cpp_opts->trigraphs = 1;
767 : 20 : break;
768 : :
769 : 2927 : case OPT_traditional_cpp:
770 : 2927 : cpp_opts->traditional = 1;
771 : 2927 : break;
772 : :
773 : 0 : case OPT_fsearch_include_path:
774 : 0 : cpp_opts->main_search = CMS_user;
775 : 0 : break;
776 : :
777 : 2 : case OPT_fsearch_include_path_:
778 : 2 : if (!strcmp (arg, "user"))
779 : 0 : cpp_opts->main_search = CMS_user;
780 : 2 : else if (!strcmp (arg, "system"))
781 : 2 : cpp_opts->main_search = CMS_system;
782 : : else
783 : 0 : error ("invalid argument %qs to %<-fsearch-include-path%>", arg);
784 : : break;
785 : :
786 : 114 : case OPT_v:
787 : 114 : verbose = true;
788 : 114 : break;
789 : : }
790 : :
791 : 3336790 : switch (c_language)
792 : : {
793 : 1440827 : case clk_c:
794 : 1440827 : C_handle_option_auto (&global_options, &global_options_set,
795 : : scode, arg, value,
796 : : c_family_lang_mask, kind,
797 : : loc, handlers, global_dc);
798 : 1440827 : break;
799 : :
800 : 0 : case clk_objc:
801 : 0 : ObjC_handle_option_auto (&global_options, &global_options_set,
802 : : scode, arg, value,
803 : : c_family_lang_mask, kind,
804 : : loc, handlers, global_dc);
805 : 0 : break;
806 : :
807 : 1895963 : case clk_cxx:
808 : 1895963 : CXX_handle_option_auto (&global_options, &global_options_set,
809 : : scode, arg, value,
810 : : c_family_lang_mask, kind,
811 : : loc, handlers, global_dc);
812 : 1895963 : break;
813 : :
814 : 0 : case clk_objcxx:
815 : 0 : ObjCXX_handle_option_auto (&global_options, &global_options_set,
816 : : scode, arg, value,
817 : : c_family_lang_mask, kind,
818 : : loc, handlers, global_dc);
819 : 0 : break;
820 : :
821 : 0 : default:
822 : 0 : gcc_unreachable ();
823 : : }
824 : :
825 : 3336790 : cpp_handle_option_auto (&global_options, scode, cpp_opts);
826 : 3336790 : return result;
827 : : }
828 : :
829 : : /* Default implementation of TARGET_HANDLE_C_OPTION. */
830 : :
831 : : bool
832 : 0 : default_handle_c_option (size_t code ATTRIBUTE_UNUSED,
833 : : const char *arg ATTRIBUTE_UNUSED,
834 : : int value ATTRIBUTE_UNUSED)
835 : : {
836 : 0 : return false;
837 : : }
838 : :
839 : : /* Post-switch processing. */
840 : : bool
841 : 211215 : c_common_post_options (const char **pfilename)
842 : : {
843 : : /* Canonicalize the input and output filenames. */
844 : 211215 : if (in_fnames == NULL)
845 : : {
846 : 0 : in_fnames = XNEWVEC (const char *, 1);
847 : 0 : in_fnames[0] = "";
848 : : }
849 : 211215 : else if (strcmp (in_fnames[0], "-") == 0)
850 : : {
851 : 407 : if (pch_file)
852 : 0 : error ("cannot use %<-%> as input filename for a precompiled header");
853 : :
854 : 407 : in_fnames[0] = "";
855 : : }
856 : :
857 : 211215 : if (out_fname == NULL || !strcmp (out_fname, "-"))
858 : 743 : out_fname = "";
859 : :
860 : 211215 : if (cpp_opts->deps.style == DEPS_NONE)
861 : 205350 : check_deps_environment_vars ();
862 : :
863 : 211215 : handle_deferred_opts ();
864 : :
865 : 211215 : sanitize_cpp_opts ();
866 : :
867 : : /* Don't register include chains if under -fpreprocessed since we might not
868 : : have correct sysroot this mode, and this may cause file permssion
869 : : issue. */
870 : 211215 : if (!cpp_opts->preprocessed)
871 : 210688 : register_include_chains (parse_in, sysroot, iprefix, imultilib,
872 : 210688 : std_inc, std_cxx_inc && c_dialect_cxx (), verbose);
873 : :
874 : : #ifdef C_COMMON_OVERRIDE_OPTIONS
875 : : /* Some machines may reject certain combinations of C
876 : : language-specific options. */
877 : : C_COMMON_OVERRIDE_OPTIONS;
878 : : #endif
879 : :
880 : 211215 : if (flag_excess_precision == EXCESS_PRECISION_DEFAULT)
881 : 362059 : flag_excess_precision = (flag_iso ? EXCESS_PRECISION_STANDARD
882 : : : EXCESS_PRECISION_FAST);
883 : :
884 : : /* ISO C restricts floating-point expression contraction to within
885 : : source-language expressions (-ffp-contract=on, currently an alias
886 : : for -ffp-contract=off). */
887 : 211215 : if (flag_iso
888 : 57201 : && !c_dialect_cxx ()
889 : 6142 : && (OPTION_SET_P (flag_fp_contract_mode)
890 : : == (enum fp_contract_mode) 0)
891 : 6142 : && flag_unsafe_math_optimizations == 0)
892 : 6137 : flag_fp_contract_mode = FP_CONTRACT_OFF;
893 : :
894 : : /* C language modes before C99 enable -fpermissive by default, but
895 : : only if -pedantic-errors is not specified. Also treat
896 : : -fno-permissive as a subset of -pedantic-errors that does not
897 : : reject certain GNU extensions also present the defaults for later
898 : : language modes. */
899 : 211215 : if (!c_dialect_cxx ()
900 : 113936 : && !flag_isoc99
901 : 6938 : && !global_dc->m_pedantic_errors
902 : 5937 : && !OPTION_SET_P (flag_permissive))
903 : : {
904 : 5936 : flag_permissive = 1;
905 : 5936 : global_dc->m_permissive = 1;
906 : : }
907 : :
908 : : /* If we are compiling C, and we are outside of a standards mode,
909 : : we can permit the new values from ISO/IEC TS 18661-3 for
910 : : FLT_EVAL_METHOD. Otherwise, we must restrict the possible values to
911 : : the set specified in ISO C99/C11. */
912 : 211215 : if (!flag_iso
913 : 154014 : && !c_dialect_cxx ()
914 : 107794 : && (OPTION_SET_P (flag_permitted_flt_eval_methods)
915 : : == PERMITTED_FLT_EVAL_METHODS_DEFAULT))
916 : 107793 : flag_permitted_flt_eval_methods = PERMITTED_FLT_EVAL_METHODS_TS_18661;
917 : : else
918 : 103422 : flag_permitted_flt_eval_methods = PERMITTED_FLT_EVAL_METHODS_C11;
919 : :
920 : 211215 : if (cxx_dialect >= cxx26)
921 : 23770 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
922 : : flag_auto_var_init, AUTO_INIT_CXX26);
923 : :
924 : : /* The -Wtrivial-auto-var-init warning is useless for C++, where we always
925 : : add .DEFERRED_INIT calls when some (vacuous) initializers are bypassed
926 : : through jumps from switch condition to case/default label. */
927 : 211215 : if (c_dialect_cxx ())
928 : 97279 : warn_trivial_auto_var_init = 0;
929 : :
930 : : /* C23 Annex F does not permit certain built-in functions to raise
931 : : "inexact". */
932 : 211215 : if (flag_isoc23)
933 : 100778 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
934 : : flag_fp_int_builtin_inexact, 0);
935 : :
936 : : /* By default we use C99 inline semantics in GNU99 or C99 mode. C99
937 : : inline semantics are not supported in GNU89 or C89 mode. */
938 : 211215 : if (flag_gnu89_inline == -1)
939 : 210772 : flag_gnu89_inline = !flag_isoc99;
940 : 443 : else if (!flag_gnu89_inline && !flag_isoc99)
941 : 1 : error ("%<-fno-gnu89-inline%> is only supported in GNU99 or C99 mode");
942 : :
943 : : /* Default to ObjC sjlj exception handling if NeXT runtime < v2. */
944 : 211215 : if (flag_objc_sjlj_exceptions < 0)
945 : 422430 : flag_objc_sjlj_exceptions = (flag_next_runtime && flag_objc_abi < 2);
946 : 211215 : if (flag_objc_exceptions && !flag_objc_sjlj_exceptions)
947 : 0 : flag_exceptions = 1;
948 : :
949 : : /* If -ffreestanding, -fno-hosted or -fno-builtin then disable
950 : : pattern recognition. */
951 : 211215 : if (flag_no_builtin)
952 : 773 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
953 : : flag_tree_loop_distribute_patterns, 0);
954 : :
955 : : /* -Woverlength-strings is off by default, but is enabled by -Wpedantic.
956 : : It is never enabled in C++, as the minimum limit is not normative
957 : : in that standard. */
958 : 211215 : if (c_dialect_cxx ())
959 : 97279 : warn_overlength_strings = 0;
960 : :
961 : : /* Wmain is enabled by default in C++ but not in C. */
962 : : /* Wmain is disabled by default for -ffreestanding (!flag_hosted),
963 : : even if -Wall or -Wpedantic was given (warn_main will be 2 if set
964 : : by -Wall, 1 if set by -Wmain). */
965 : 211215 : if (warn_main == -1)
966 : 258140 : warn_main = (c_dialect_cxx () && flag_hosted) ? 1 : 0;
967 : 55810 : else if (warn_main == 2)
968 : 55489 : warn_main = flag_hosted ? 1 : 0;
969 : :
970 : : /* In C, -Wall and -Wc++-compat enable -Wenum-compare; if it has not
971 : : yet been set, it is disabled by default. In C++, it is enabled
972 : : by default. */
973 : 211215 : if (warn_enum_compare == -1)
974 : 201727 : warn_enum_compare = c_dialect_cxx () ? 1 : 0;
975 : :
976 : : /* For C++26 default to -Wkeyword-macro if -Wpedantic. */
977 : 211215 : if (cxx_dialect >= cxx26 && pedantic)
978 : : {
979 : 14102 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
980 : : warn_keyword_macro, 1);
981 : 14102 : if (warn_keyword_macro)
982 : 14101 : cpp_opts->cpp_warn_keyword_macro = warn_keyword_macro;
983 : : }
984 : :
985 : : /* -Wpacked-bitfield-compat is on by default for the C languages. The
986 : : warning is issued in stor-layout.cc which is not part of the front-end so
987 : : we need to selectively turn it on here. */
988 : 211215 : if (warn_packed_bitfield_compat == -1)
989 : 211207 : warn_packed_bitfield_compat = 1;
990 : :
991 : : /* Special format checking options don't work without -Wformat; warn if
992 : : they are used. */
993 : 211215 : if (!warn_format)
994 : : {
995 : 199975 : warning (OPT_Wformat_y2k,
996 : : "%<-Wformat-y2k%> ignored without %<-Wformat%>");
997 : 199975 : warning (OPT_Wformat_extra_args,
998 : : "%<-Wformat-extra-args%> ignored without %<-Wformat%>");
999 : 199975 : warning (OPT_Wformat_zero_length,
1000 : : "%<-Wformat-zero-length%> ignored without %<-Wformat%>");
1001 : 199975 : warning (OPT_Wformat_nonliteral,
1002 : : "%<-Wformat-nonliteral%> ignored without %<-Wformat%>");
1003 : 199975 : warning (OPT_Wformat_contains_nul,
1004 : : "%<-Wformat-contains-nul%> ignored without %<-Wformat%>");
1005 : 199975 : warning (OPT_Wformat_security,
1006 : : "%<-Wformat-security%> ignored without %<-Wformat%>");
1007 : : }
1008 : :
1009 : : /* -Wimplicit-function-declaration is enabled by default for C99. */
1010 : 211215 : if (warn_implicit_function_declaration == -1)
1011 : 202873 : warn_implicit_function_declaration = flag_isoc99;
1012 : :
1013 : : /* -Wimplicit-int is enabled by default for C99. */
1014 : 211215 : if (warn_implicit_int == -1)
1015 : 202930 : warn_implicit_int = flag_isoc99;
1016 : :
1017 : : /* -Wold-style-definition is enabled by default for C23. */
1018 : 211215 : if (warn_old_style_definition == -1)
1019 : 206922 : warn_old_style_definition = flag_isoc23;
1020 : :
1021 : : /* -Wshift-overflow is enabled by default in C99 and C++11 modes. */
1022 : 211215 : if (warn_shift_overflow == -1)
1023 : 401312 : warn_shift_overflow = cxx_dialect >= cxx11 || flag_isoc99;
1024 : :
1025 : : /* -Wmissing-parameter-name is enabled by -pedantic before C23,
1026 : : and for -Wc11-c23-compat. */
1027 : 211215 : if (warn_missing_parameter_name == -1)
1028 : 211212 : warn_missing_parameter_name
1029 : 47239 : = ((pedantic && !flag_isoc23 && warn_c11_c23_compat != 0)
1030 : 258496 : || warn_c11_c23_compat > 0);
1031 : :
1032 : : /* Likewise for -Wfree-labels. */
1033 : 211215 : if (warn_free_labels == -1)
1034 : 47239 : warn_free_labels = ((pedantic && !flag_isoc23 && warn_c11_c23_compat != 0)
1035 : 258496 : || warn_c11_c23_compat > 0);
1036 : :
1037 : 211215 : if (warn_deprecated_non_prototype == -1)
1038 : 211210 : warn_deprecated_non_prototype = warn_c11_c23_compat > 0;
1039 : :
1040 : : /* -Wshift-negative-value is enabled by -Wextra in C99 and C++11 to C++17
1041 : : modes. */
1042 : 211215 : if (warn_shift_negative_value == -1)
1043 : 422390 : warn_shift_negative_value = (extra_warnings
1044 : 7766 : && (cxx_dialect >= cxx11 || flag_isoc99)
1045 : 422737 : && cxx_dialect < cxx20);
1046 : :
1047 : : /* -Wregister is enabled by default in C++17. */
1048 : 211215 : SET_OPTION_IF_UNSET (&global_options, &global_options_set, warn_register,
1049 : : cxx_dialect >= cxx17);
1050 : :
1051 : : /* Explicit -Wdeprecated turns on warnings from later standards. */
1052 : 1652999 : auto deprecated_in = [&](enum cxx_dialect d)
1053 : : {
1054 : 1441784 : if (OPTION_SET_P (warn_deprecated)) return !!warn_deprecated;
1055 : 1440296 : return (warn_deprecated && cxx_dialect >= d);
1056 : : };
1057 : :
1058 : : /* -Wcomma-subscript is enabled by default in C++20. */
1059 : 211215 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
1060 : : warn_comma_subscript,
1061 : : cxx_dialect >= cxx23
1062 : : || deprecated_in (cxx20));
1063 : :
1064 : : /* -Wvolatile is enabled by default in C++20. */
1065 : 211215 : SET_OPTION_IF_UNSET (&global_options, &global_options_set, warn_volatile,
1066 : : deprecated_in (cxx20));
1067 : :
1068 : : /* -Wdeprecated-enum-enum-conversion is enabled by default in C++20. */
1069 : 211215 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
1070 : : warn_deprecated_enum_enum_conv,
1071 : : deprecated_in (cxx20));
1072 : :
1073 : : /* -Wdeprecated-enum-float-conversion is enabled by default in C++20. */
1074 : 211215 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
1075 : : warn_deprecated_enum_float_conv,
1076 : : deprecated_in (cxx20));
1077 : :
1078 : : /* -Wdeprecated-literal-operator is enabled by default in C++23. */
1079 : 211215 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
1080 : : warn_deprecated_literal_operator,
1081 : : deprecated_in (cxx23));
1082 : :
1083 : : /* -Warray-compare is enabled by default in C++20. */
1084 : 211215 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
1085 : : warn_array_compare,
1086 : : warn_array_compare || deprecated_in (cxx20));
1087 : :
1088 : : /* -Wdeprecated-variadic-comma-omission is enabled by default in C++26. */
1089 : 211215 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
1090 : : warn_deprecated_variadic_comma_omission,
1091 : : deprecated_in (cxx26));
1092 : :
1093 : : /* -Wtemplate-id-cdtor is enabled by default in C++20. */
1094 : 277024 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
1095 : : warn_template_id_cdtor,
1096 : : cxx_dialect >= cxx20 || warn_cxx20_compat);
1097 : :
1098 : : /* Declone C++ 'structors if -Os. */
1099 : 211215 : if (flag_declone_ctor_dtor == -1)
1100 : 211178 : flag_declone_ctor_dtor = optimize_size;
1101 : :
1102 : 211215 : if (flag_abi_compat_version == 1)
1103 : : {
1104 : 0 : warning (0, "%<-fabi-compat-version=1%> is not supported, using =2");
1105 : 0 : flag_abi_compat_version = 2;
1106 : : }
1107 : :
1108 : : /* Change flag_abi_version to be the actual current ABI level, for the
1109 : : benefit of c_cpp_builtins, and to make comparison simpler. */
1110 : 211215 : const int latest_abi_version = 21;
1111 : : /* Possibly different for non-default ABI fixes within a release. */
1112 : 211215 : const int default_abi_version = latest_abi_version;
1113 : : /* Generate compatibility aliases for ABI v18 (GCC 13) by default. */
1114 : 211215 : const int abi_compat_default = 18;
1115 : :
1116 : 211215 : if (flag_abi_version > latest_abi_version)
1117 : 0 : warning (0, "%<-fabi-version=%d%> is not supported, using =%d",
1118 : : flag_abi_version, latest_abi_version);
1119 : :
1120 : 211215 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
1121 : : flag_abi_version, default_abi_version);
1122 : :
1123 : : #define clamp(X) if (X == 0 || X > latest_abi_version) X = latest_abi_version
1124 : 211215 : clamp (flag_abi_version);
1125 : : /* Don't clamp warn_abi_version, let it be 0 or out of bounds. */
1126 : 211215 : clamp (flag_abi_compat_version);
1127 : : #undef clamp
1128 : :
1129 : : /* Default -Wabi= or -fabi-compat-version= from each other. */
1130 : 211215 : if (warn_abi_version == -1 && flag_abi_compat_version != -1)
1131 : 197 : warn_abi_version = flag_abi_compat_version;
1132 : 211018 : else if (flag_abi_compat_version == -1 && warn_abi_version != -1)
1133 : 13390 : flag_abi_compat_version = warn_abi_version;
1134 : 197628 : else if (warn_abi_version == -1 && flag_abi_compat_version == -1)
1135 : : {
1136 : 197583 : warn_abi_version = 0;
1137 : 197583 : if (flag_abi_version == default_abi_version)
1138 : 197348 : flag_abi_compat_version = abi_compat_default;
1139 : : else
1140 : 235 : flag_abi_compat_version = latest_abi_version;
1141 : : }
1142 : :
1143 : : /* Allow warnings vs ABI versions beyond what we currently support. */
1144 : 211215 : if (warn_abi_version == 0)
1145 : 197598 : warn_abi_version = 1000;
1146 : :
1147 : : /* By default, enable the new inheriting constructor semantics along with ABI
1148 : : 11. New and old should coexist fine, but it is a change in what
1149 : : artificial symbols are generated. */
1150 : 422174 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
1151 : : flag_new_inheriting_ctors,
1152 : : abi_version_at_least (11));
1153 : :
1154 : : /* For GCC 7, only enable DR150 resolution by default if -std=c++17. */
1155 : 211215 : SET_OPTION_IF_UNSET (&global_options, &global_options_set, flag_new_ttp,
1156 : : cxx_dialect >= cxx17);
1157 : :
1158 : : /* C++11 guarantees forward progress. */
1159 : 396077 : SET_OPTION_IF_UNSET (&global_options, &global_options_set, flag_finite_loops,
1160 : : optimize >= 2 && cxx_dialect >= cxx11);
1161 : :
1162 : : /* It's OK to discard calls to pure/const functions that might throw. */
1163 : 211215 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
1164 : : flag_delete_dead_exceptions, true);
1165 : :
1166 : 211215 : if (cxx_dialect >= cxx11)
1167 : : {
1168 : : /* If we're allowing C++0x constructs, don't warn about C++98
1169 : : identifiers which are keywords in C++0x. */
1170 : 83202 : warn_cxx11_compat = 0;
1171 : 83202 : cpp_opts->cpp_warn_cxx11_compat = 0;
1172 : :
1173 : 83202 : if (warn_narrowing == -1)
1174 : 81028 : warn_narrowing = 1;
1175 : :
1176 : : /* Unless -f{,no-}ext-numeric-literals has been used explicitly,
1177 : : for -std=c++{11,14,17,20,23,26} default to
1178 : : -fno-ext-numeric-literals. */
1179 : 83202 : if (flag_iso && !OPTION_SET_P (flag_ext_numeric_literals))
1180 : 42244 : cpp_opts->ext_numeric_literals = 0;
1181 : : }
1182 : 128013 : else if (warn_narrowing == -1)
1183 : 127524 : warn_narrowing = 0;
1184 : :
1185 : 211215 : if (cxx_dialect >= cxx20)
1186 : : {
1187 : : /* Don't warn about C++20 compatibility changes in C++20 or later. */
1188 : 64386 : warn_cxx20_compat = 0;
1189 : 64386 : cpp_opts->cpp_warn_cxx20_compat = 0;
1190 : : }
1191 : 211215 : if (cxx_dialect >= cxx26)
1192 : : /* Don't warn about C++26 compatibility changes in C++26 or later. */
1193 : 23770 : warn_cxx26_compat = 0;
1194 : :
1195 : : /* C++17 has stricter evaluation order requirements; let's use some of them
1196 : : for earlier C++ as well, so chaining works as expected. */
1197 : 211215 : if (c_dialect_cxx ()
1198 : 97279 : && flag_strong_eval_order == -1)
1199 : 118201 : flag_strong_eval_order = (cxx_dialect >= cxx17 ? 2 : 1);
1200 : :
1201 : 211215 : if (flag_implicit_constexpr && cxx_dialect < cxx14)
1202 : 0 : flag_implicit_constexpr = false;
1203 : :
1204 : : /* Global sized deallocation is new in C++14. */
1205 : 211215 : if (flag_sized_deallocation == -1)
1206 : 211211 : flag_sized_deallocation = (cxx_dialect >= cxx14);
1207 : :
1208 : : /* Pedwarn about invalid constexpr functions before C++23. */
1209 : 211215 : if (warn_invalid_constexpr == -1)
1210 : 211199 : warn_invalid_constexpr = (cxx_dialect < cxx23);
1211 : :
1212 : : /* char8_t support is implicitly enabled in C++20 and C23. */
1213 : 211215 : if (flag_char8_t == -1)
1214 : 376238 : flag_char8_t = (cxx_dialect >= cxx20) || flag_isoc23;
1215 : 211215 : cpp_opts->unsigned_utf8char = flag_char8_t ? 1 : cpp_opts->unsigned_char;
1216 : :
1217 : 211215 : cpp_opts->cpp_tabstop = global_dc->get_column_options ().m_tabstop;
1218 : :
1219 : 211215 : if (flag_extern_tls_init)
1220 : : {
1221 : 211213 : if (!TARGET_SUPPORTS_ALIASES || !SUPPORTS_WEAK)
1222 : : {
1223 : : /* Lazy TLS initialization for a variable in another TU requires
1224 : : alias and weak reference support. */
1225 : : if (flag_extern_tls_init > 0)
1226 : : sorry ("external TLS initialization functions not supported "
1227 : : "on this target");
1228 : :
1229 : : flag_extern_tls_init = 0;
1230 : : }
1231 : : else
1232 : 211213 : flag_extern_tls_init = 1;
1233 : : }
1234 : :
1235 : : /* Enable by default only for C++ and C++ with ObjC extensions. */
1236 : 211215 : if (warn_return_type == -1 && c_dialect_cxx ())
1237 : 93768 : warn_return_type = 1;
1238 : :
1239 : : /* C++20 is the final version of concepts. We still use -fconcepts
1240 : : to know when concepts are enabled. */
1241 : 211215 : if (cxx_dialect >= cxx20)
1242 : 64386 : flag_concepts = 1;
1243 : :
1244 : : /* Coroutines are also a C++20 feature. */
1245 : 211215 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
1246 : : flag_coroutines, cxx_dialect >= cxx20);
1247 : :
1248 : : /* Enable lifetime extension of range based for temporaries for C++23. */
1249 : 211215 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
1250 : : flag_range_for_ext_temps, cxx_dialect >= cxx23);
1251 : :
1252 : : /* EnabledBy unfortunately can't specify value to use if set and
1253 : : LangEnabledBy can't specify multiple options with &&. For -Wunused
1254 : : or -Wunused -Wextra we want these to default to 3 unless user specified
1255 : : some other level explicitly. */
1256 : 211215 : if (warn_unused_but_set_parameter == 1)
1257 : 7610 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
1258 : : warn_unused_but_set_parameter, 3);
1259 : 211215 : if (warn_unused_but_set_variable == 1)
1260 : 10436 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
1261 : : warn_unused_but_set_variable, 3);
1262 : :
1263 : : /* -fimmediate-escalation has no effect when immediate functions are not
1264 : : supported. */
1265 : 211215 : if (flag_immediate_escalation && cxx_dialect < cxx20)
1266 : 146829 : flag_immediate_escalation = 0;
1267 : :
1268 : 211215 : if (num_in_fnames > 1)
1269 : 0 : error ("too many filenames given; type %<%s %s%> for usage",
1270 : : progname, "--help");
1271 : :
1272 : 211215 : if (flag_preprocess_only)
1273 : : {
1274 : : /* Open the output now. We must do so even if flag_no_output is
1275 : : on, because there may be other output than from the actual
1276 : : preprocessing (e.g. from -dM). */
1277 : 6812 : if (out_fname[0] == '\0')
1278 : 743 : out_stream = stdout;
1279 : : else
1280 : 6069 : out_stream = fopen (out_fname, "w");
1281 : :
1282 : 6812 : if (out_stream == NULL)
1283 : 0 : fatal_error (input_location, "opening output file %s: %m", out_fname);
1284 : :
1285 : 6812 : init_pp_output (out_stream);
1286 : : }
1287 : : else
1288 : : {
1289 : 204403 : init_c_lex ();
1290 : :
1291 : : /* When writing a PCH file, avoid reading some other PCH file,
1292 : : because the default address space slot then can't be used
1293 : : for the output PCH file. */
1294 : 204403 : if (pch_file)
1295 : : {
1296 : 464 : c_common_no_more_pch ();
1297 : : /* Only -g0 and -gdwarf* are supported with PCH, for other
1298 : : debug formats we warn here and refuse to load any PCH files. */
1299 : 464 : if (write_symbols != NO_DEBUG && write_symbols != DWARF2_DEBUG)
1300 : 0 : warning (OPT_Wdeprecated,
1301 : : "the %qs debug info cannot be used with "
1302 : : "pre-compiled headers",
1303 : : debug_set_names (write_symbols & ~DWARF2_DEBUG));
1304 : : /* Let libcpp know that the main file is a header so it won't
1305 : : complain about things like #include_next and #pragma once. */
1306 : 464 : cpp_opts->main_search = CMS_header;
1307 : : }
1308 : 203939 : else if (write_symbols != NO_DEBUG && write_symbols != DWARF2_DEBUG)
1309 : 472 : c_common_no_more_pch ();
1310 : :
1311 : : /* Yuk. WTF is this? I do know ObjC relies on it somewhere. */
1312 : 204403 : input_location = UNKNOWN_LOCATION;
1313 : : }
1314 : :
1315 : 211215 : struct cpp_callbacks *cb = cpp_get_callbacks (parse_in);
1316 : 211215 : cb->file_change = cb_file_change;
1317 : 211215 : cb->dir_change = cb_dir_change;
1318 : 211215 : if (lang_hooks.preprocess_options)
1319 : 97279 : lang_hooks.preprocess_options (parse_in);
1320 : 211215 : cpp_post_options (parse_in);
1321 : 211215 : init_global_opts_from_cpp (&global_options, cpp_get_options (parse_in));
1322 : : /* For C++23 and explicit -finput-charset=UTF-8, turn on -Winvalid-utf8
1323 : : by default and make it a pedwarn unless -Wno-invalid-utf8. */
1324 : 211215 : if (cxx_dialect >= cxx23
1325 : 25731 : && cpp_opts->cpp_input_charset_explicit
1326 : 23 : && strcmp (cpp_opts->input_charset, "UTF-8") == 0
1327 : 21 : && (cpp_opts->cpp_warn_invalid_utf8
1328 : 16 : || !global_options_set.x_warn_invalid_utf8))
1329 : : {
1330 : 18 : global_options.x_warn_invalid_utf8 = 1;
1331 : 28 : cpp_opts->cpp_warn_invalid_utf8 = cpp_opts->cpp_pedantic ? 2 : 1;
1332 : : }
1333 : :
1334 : : /* Let diagnostics infrastructure know how to convert input files the same
1335 : : way libcpp will do it, namely using the configured input charset and
1336 : : skipping a UTF-8 BOM if present. */
1337 : 211215 : diagnostic_initialize_input_context (global_dc,
1338 : : c_common_input_charset_cb, true);
1339 : 211215 : input_location = UNKNOWN_LOCATION;
1340 : :
1341 : 422430 : *pfilename = this_input_filename
1342 : 422430 : = cpp_read_main_file (parse_in, in_fnames[0],
1343 : : /* We'll inject preamble pieces if this is
1344 : : not preprocessed. */
1345 : 211215 : !cpp_opts->preprocessed);
1346 : :
1347 : : /* Don't do any compilation or preprocessing if there is no input file. */
1348 : 211215 : if (this_input_filename == NULL)
1349 : : {
1350 : 0 : errorcount++;
1351 : 0 : return false;
1352 : : }
1353 : :
1354 : 211215 : if (flag_working_directory
1355 : 42874 : && flag_preprocess_only && !flag_no_line_commands)
1356 : 2300 : pp_dir_change (parse_in, get_src_pwd ());
1357 : :
1358 : : /* Disable LTO output when outputting a precompiled header. */
1359 : 211215 : if (pch_file && flag_lto)
1360 : : {
1361 : 0 : flag_lto = 0;
1362 : 0 : flag_generate_lto = 0;
1363 : : }
1364 : :
1365 : 211215 : return flag_preprocess_only;
1366 : : }
1367 : :
1368 : : /* Front end initialization common to C, ObjC and C++. */
1369 : : bool
1370 : 210994 : c_common_init (void)
1371 : : {
1372 : : /* Set up preprocessor arithmetic. Must be done after call to
1373 : : c_common_nodes_and_builtins for type nodes to be good. */
1374 : 210994 : cpp_opts->precision = TYPE_PRECISION (intmax_type_node);
1375 : 210994 : cpp_opts->char_precision = TYPE_PRECISION (char_type_node);
1376 : 210994 : cpp_opts->int_precision = TYPE_PRECISION (integer_type_node);
1377 : 210994 : cpp_opts->wchar_precision = TYPE_PRECISION (wchar_type_node);
1378 : 210994 : cpp_opts->unsigned_wchar = TYPE_UNSIGNED (wchar_type_node);
1379 : 210994 : cpp_opts->bytes_big_endian = BYTES_BIG_ENDIAN;
1380 : :
1381 : : /* This can't happen until after wchar_precision and bytes_big_endian
1382 : : are known. */
1383 : 210994 : cpp_init_iconv (parse_in);
1384 : :
1385 : 210994 : if (version_flag)
1386 : : {
1387 : 111 : int i;
1388 : 111 : fputs ("Compiler executable checksum: ", stderr);
1389 : 1998 : for (i = 0; i < 16; i++)
1390 : 1776 : fprintf (stderr, "%02x", executable_checksum[i]);
1391 : 111 : putc ('\n', stderr);
1392 : : }
1393 : :
1394 : : /* Has to wait until now so that cpplib has its hash table. */
1395 : 210994 : init_pragma ();
1396 : :
1397 : 210994 : if (flag_preprocess_only)
1398 : : {
1399 : 6807 : c_init_preprocess ();
1400 : 6807 : c_finish_options ();
1401 : 6807 : preprocess_file (parse_in);
1402 : 6807 : return false;
1403 : : }
1404 : :
1405 : : return true;
1406 : : }
1407 : :
1408 : : /* Initialize the integrated preprocessor after debug output has been
1409 : : initialized; loop over each input file. */
1410 : : void
1411 : 204187 : c_common_parse_file (void)
1412 : : {
1413 : 204187 : auto dumps = g->get_dumps ();
1414 : 204187 : for (unsigned int i = 0;;)
1415 : : {
1416 : 204187 : c_finish_options ();
1417 : : /* Open the dump file to use for the original dump output
1418 : : here, to be used during parsing for the current file. */
1419 : 204187 : dumps->dump_start (TDI_original, &dump_flags);
1420 : 204187 : pch_init ();
1421 : 204187 : push_file_scope ();
1422 : 204187 : c_parse_file ();
1423 : 203891 : pop_file_scope ();
1424 : : /* And end the main input file, if the debug writer wants it */
1425 : 203891 : if (debug_hooks->start_end_main_source_file)
1426 : 40386 : (*debug_hooks->end_source_file) (0);
1427 : 203891 : if (++i >= num_in_fnames)
1428 : : break;
1429 : 0 : cpp_undef_all (parse_in);
1430 : 0 : cpp_clear_file_cache (parse_in);
1431 : 0 : this_input_filename
1432 : 0 : = cpp_read_main_file (parse_in, in_fnames[i]);
1433 : : /* If an input file is missing, abandon further compilation.
1434 : : cpplib has issued a diagnostic. */
1435 : 0 : if (!this_input_filename)
1436 : : break;
1437 : 0 : dumps->dump_finish (TDI_original);
1438 : : }
1439 : :
1440 : 203891 : c_parse_final_cleanups ();
1441 : 203879 : dumps->dump_finish (TDI_original);
1442 : 203879 : }
1443 : :
1444 : : /* Common finish hook for the C, ObjC and C++ front ends. */
1445 : : void
1446 : 210493 : c_common_finish (void)
1447 : : {
1448 : 210493 : FILE *deps_stream = NULL;
1449 : 210493 : FILE *fdeps_stream = NULL;
1450 : :
1451 : : /* Note that we write the dependencies even if there are errors. This is
1452 : : useful for handling outdated generated headers that now trigger errors
1453 : : (for example, with #error) which would be resolved by re-generating
1454 : : them. In a sense, this complements -MG. */
1455 : 210493 : if (cpp_opts->deps.style != DEPS_NONE)
1456 : : {
1457 : : /* If -M or -MM was seen without -MF, default output to the
1458 : : output stream. */
1459 : 5860 : if (!deps_file)
1460 : 22 : deps_stream = out_stream;
1461 : 5838 : else if (deps_file[0] == '-' && deps_file[1] == '\0')
1462 : 0 : deps_stream = stdout;
1463 : : else
1464 : : {
1465 : 11676 : deps_stream = fopen (deps_file, deps_append ? "a" : "w");
1466 : 5838 : if (!deps_stream)
1467 : 0 : fatal_error (input_location, "opening dependency file %s: %m",
1468 : : deps_file);
1469 : : }
1470 : : }
1471 : :
1472 : : /* When we call cpp_finish (), it may generate some diagnostics using
1473 : : locations it remembered from the preprocessing phase, e.g. for
1474 : : -Wunused-macros. So inform c_cpp_diagnostic () not to override those
1475 : : locations with input_location, which would be incorrect now. */
1476 : 210493 : override_libcpp_locations = false;
1477 : :
1478 : 210493 : if (cpp_opts->deps.fdeps_format != FDEPS_FMT_NONE)
1479 : : {
1480 : 36 : if (!fdeps_file)
1481 : 0 : fdeps_stream = out_stream;
1482 : 36 : else if (fdeps_file[0] == '-' && fdeps_file[1] == '\0')
1483 : 0 : fdeps_stream = stdout;
1484 : : else
1485 : : {
1486 : 36 : fdeps_stream = fopen (fdeps_file, "w");
1487 : 36 : if (!fdeps_stream)
1488 : 0 : fatal_error (input_location, "opening dependency file %s: %m",
1489 : : fdeps_file);
1490 : : }
1491 : 36 : if (fdeps_stream == deps_stream && fdeps_stream != stdout)
1492 : 0 : fatal_error (input_location, "%<-MF%> and %<-fdeps-file=%> cannot share an output file %s: %m",
1493 : : fdeps_file);
1494 : : }
1495 : :
1496 : : /* For performance, avoid tearing down cpplib's internal structures
1497 : : with cpp_destroy (). */
1498 : 210493 : cpp_finish (parse_in, deps_stream, fdeps_stream);
1499 : :
1500 : 5860 : if (deps_stream && deps_stream != out_stream && deps_stream != stdout
1501 : 216331 : && (ferror (deps_stream) || fclose (deps_stream)))
1502 : 0 : fatal_error (input_location, "closing dependency file %s: %m", deps_file);
1503 : :
1504 : 210493 : if (out_stream && (ferror (out_stream) || fclose (out_stream)))
1505 : 0 : fatal_error (input_location, "when writing output to %s: %m", out_fname);
1506 : 210493 : }
1507 : :
1508 : : /* Either of two environment variables can specify output of
1509 : : dependencies. Their value is either "OUTPUT_FILE" or "OUTPUT_FILE
1510 : : DEPS_TARGET", where OUTPUT_FILE is the file to write deps info to
1511 : : and DEPS_TARGET is the target to mention in the deps. They also
1512 : : result in dependency information being appended to the output file
1513 : : rather than overwriting it, and like Sun's compiler
1514 : : SUNPRO_DEPENDENCIES suppresses the dependency on the main file. */
1515 : : static void
1516 : 205350 : check_deps_environment_vars (void)
1517 : : {
1518 : 205350 : char *spec;
1519 : :
1520 : 205350 : spec = getenv ("DEPENDENCIES_OUTPUT");
1521 : 205350 : if (spec)
1522 : 0 : cpp_opts->deps.style = DEPS_USER;
1523 : : else
1524 : : {
1525 : 205350 : spec = getenv ("SUNPRO_DEPENDENCIES");
1526 : 205350 : if (spec)
1527 : : {
1528 : 0 : cpp_opts->deps.style = DEPS_SYSTEM;
1529 : 0 : cpp_opts->deps.ignore_main_file = true;
1530 : : }
1531 : : }
1532 : :
1533 : 0 : if (spec)
1534 : : {
1535 : : /* Find the space before the DEPS_TARGET, if there is one. */
1536 : 0 : char *s = strchr (spec, ' ');
1537 : 0 : if (s)
1538 : : {
1539 : : /* Let the caller perform MAKE quoting. */
1540 : 0 : defer_opt (OPT_MT, s + 1);
1541 : 0 : *s = '\0';
1542 : : }
1543 : :
1544 : : /* Command line -MF overrides environment variables and default. */
1545 : 0 : if (!deps_file)
1546 : 0 : deps_file = spec;
1547 : :
1548 : 0 : deps_append = 1;
1549 : 0 : deps_seen = true;
1550 : : }
1551 : 205350 : }
1552 : :
1553 : : /* Handle deferred command line switches. */
1554 : : static void
1555 : 211215 : handle_deferred_opts (void)
1556 : : {
1557 : : /* Avoid allocating the deps buffer if we don't need it.
1558 : : (This flag may be true without there having been -MT or -MQ
1559 : : options, but we'll still need the deps buffer.) */
1560 : 211215 : if (!deps_seen)
1561 : : return;
1562 : :
1563 : 5867 : if (mkdeps *deps = cpp_get_deps (parse_in))
1564 : 34840 : for (unsigned i = 0; i < deferred_count; i++)
1565 : : {
1566 : 28997 : struct deferred_opt *opt = &deferred_opts[i];
1567 : :
1568 : 28997 : if (opt->code == OPT_MT || opt->code == OPT_MQ)
1569 : 5836 : deps_add_target (deps, opt->arg, opt->code == OPT_MQ);
1570 : 23161 : else if (opt->code == OPT_fdeps_target_)
1571 : 42 : fdeps_add_target (deps, opt->arg, true);
1572 : : }
1573 : : }
1574 : :
1575 : : /* These settings are appropriate for GCC, but not necessarily so for
1576 : : cpplib as a library. */
1577 : : static void
1578 : 211215 : sanitize_cpp_opts (void)
1579 : : {
1580 : : /* If we don't know what style of dependencies to output, complain
1581 : : if any other dependency switches have been given. */
1582 : 211215 : if (deps_seen && cpp_opts->deps.style == DEPS_NONE)
1583 : 24 : error ("to generate dependencies you must specify either %<-M%> "
1584 : : "or %<-MM%>");
1585 : :
1586 : : /* -dM and dependencies suppress normal output; do it here so that
1587 : : the last -d[MDN] switch overrides earlier ones. */
1588 : 211215 : if (flag_dump_macros == 'M')
1589 : 80 : flag_no_output = 1;
1590 : :
1591 : : /* By default, -fdirectives-only implies -dD. This allows subsequent phases
1592 : : to perform proper macro expansion. */
1593 : 211215 : if (cpp_opts->directives_only && !cpp_opts->preprocessed && !flag_dump_macros)
1594 : 69 : flag_dump_macros = 'D';
1595 : :
1596 : : /* Disable -dD, -dN and -dI if normal output is suppressed. Allow
1597 : : -dM since at least glibc relies on -M -dM to work. */
1598 : : /* Also, flag_no_output implies flag_no_line_commands, always. */
1599 : 211215 : if (flag_no_output)
1600 : : {
1601 : 104 : if (flag_dump_macros != 'M')
1602 : 24 : flag_dump_macros = 0;
1603 : 104 : flag_dump_includes = 0;
1604 : 104 : flag_no_line_commands = 1;
1605 : : }
1606 : 211111 : else if (cpp_opts->deps.missing_files)
1607 : 1 : error ("%<-MG%> may only be used with %<-M%> or %<-MM%>");
1608 : :
1609 : 211215 : cpp_opts->unsigned_char = !flag_signed_char;
1610 : 211215 : cpp_opts->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;
1611 : :
1612 : : /* Wlong-long is disabled by default. It is enabled by:
1613 : : [-Wpedantic | -Wtraditional] -std=[gnu|c]++98 ; or
1614 : : [-Wpedantic | -Wtraditional] -std=non-c99
1615 : :
1616 : : Either -Wlong-long or -Wno-long-long override any other settings.
1617 : : ??? These conditions should be handled in c.opt. */
1618 : 211215 : if (warn_long_long == -1)
1619 : : {
1620 : 163221 : warn_long_long = ((pedantic || warn_traditional)
1621 : 166932 : && (c_dialect_cxx () ? cxx_dialect == cxx98 : !flag_isoc99));
1622 : 166908 : cpp_opts->cpp_warn_long_long = warn_long_long;
1623 : : }
1624 : :
1625 : : /* If we're generating preprocessor output, emit current directory
1626 : : if explicitly requested or if debugging information is enabled.
1627 : : ??? Maybe we should only do it for debugging formats that
1628 : : actually output the current directory? */
1629 : 211215 : if (flag_working_directory == -1)
1630 : 209865 : flag_working_directory = (debug_info_level != DINFO_LEVEL_NONE);
1631 : :
1632 : 211215 : if (warn_implicit_fallthrough < 5)
1633 : 211211 : cpp_opts->cpp_warn_implicit_fallthrough = warn_implicit_fallthrough;
1634 : : else
1635 : 4 : cpp_opts->cpp_warn_implicit_fallthrough = 0;
1636 : :
1637 : 211215 : if (cpp_opts->directives_only)
1638 : : {
1639 : 110 : if (cpp_warn_unused_macros)
1640 : 4 : error ("%<-fdirectives-only%> is incompatible "
1641 : : "with %<-Wunused-macros%>");
1642 : 110 : if (cpp_opts->traditional)
1643 : 1 : error ("%<-fdirectives-only%> is incompatible with %<-traditional%>");
1644 : : }
1645 : 211215 : }
1646 : :
1647 : : /* Add include path with a prefix at the front of its name. */
1648 : : static void
1649 : 0 : add_prefixed_path (const char *suffix, incpath_kind chain)
1650 : : {
1651 : 0 : char *path;
1652 : 0 : const char *prefix;
1653 : 0 : size_t prefix_len, suffix_len;
1654 : :
1655 : 0 : suffix_len = strlen (suffix);
1656 : 0 : prefix = iprefix ? iprefix : cpp_GCC_INCLUDE_DIR;
1657 : 0 : prefix_len = iprefix ? strlen (iprefix) : cpp_GCC_INCLUDE_DIR_len;
1658 : :
1659 : 0 : path = (char *) xmalloc (prefix_len + suffix_len + 1);
1660 : 0 : memcpy (path, prefix, prefix_len);
1661 : 0 : memcpy (path + prefix_len, suffix, suffix_len);
1662 : 0 : path[prefix_len + suffix_len] = '\0';
1663 : :
1664 : 0 : add_path (path, chain, 0, false);
1665 : 0 : }
1666 : :
1667 : : /* Handle -D, -U, -A, -imacros, and the first -include. */
1668 : : static void
1669 : 210994 : c_finish_options (void)
1670 : : {
1671 : 210994 : if (!cpp_opts->preprocessed)
1672 : : {
1673 : 210467 : const line_map_ordinary *bltin_map
1674 : 210467 : = linemap_check_ordinary (linemap_add (line_table, LC_RENAME, 0,
1675 : : special_fname_builtin (), 0));
1676 : 210467 : cb_file_change (parse_in, bltin_map);
1677 : 210467 : linemap_line_start (line_table, 0, 1);
1678 : :
1679 : : /* Make sure all of the builtins about to be declared have
1680 : : BUILTINS_LOCATION has their location_t. */
1681 : 210467 : cpp_force_token_locations (parse_in, BUILTINS_LOCATION);
1682 : :
1683 : 210467 : cpp_init_builtins (parse_in, flag_hosted);
1684 : 210467 : c_cpp_builtins (parse_in);
1685 : :
1686 : : /* We're about to send user input to cpplib, so make it warn for
1687 : : things that we previously (when we sent it internal definitions)
1688 : : told it to not warn.
1689 : :
1690 : : C99 permits implementation-defined characters in identifiers.
1691 : : The documented meaning of -std= is to turn off extensions that
1692 : : conflict with the specified standard, and since a strictly
1693 : : conforming program cannot contain a '$', we do not condition
1694 : : their acceptance on the -std= setting. */
1695 : 210467 : cpp_opts->warn_dollars = (cpp_opts->cpp_pedantic && !cpp_opts->c99);
1696 : :
1697 : 210467 : const line_map_ordinary *cmd_map
1698 : 210467 : = linemap_check_ordinary (linemap_add (line_table, LC_RENAME, 0,
1699 : 210467 : _("<command-line>"), 0));
1700 : 210467 : cb_file_change (parse_in, cmd_map);
1701 : 210467 : linemap_line_start (line_table, 0, 1);
1702 : :
1703 : 210467 : bool fortify_seen_p = false;
1704 : 210467 : bool cxx_assert_seen_p = false;
1705 : :
1706 : : /* All command line defines must have the same location. */
1707 : 210467 : line_table->cmdline_location = line_table->highest_line;
1708 : 210467 : cpp_force_token_locations (parse_in, line_table->highest_line);
1709 : 391511 : for (size_t i = 0; i < deferred_count; i++)
1710 : : {
1711 : 181044 : struct deferred_opt *opt = &deferred_opts[i];
1712 : :
1713 : 181044 : if (opt->code == OPT_D)
1714 : 164924 : cpp_define (parse_in, opt->arg);
1715 : 16120 : else if (opt->code == OPT_U)
1716 : 61 : cpp_undef (parse_in, opt->arg);
1717 : 16059 : else if (opt->code == OPT_A)
1718 : : {
1719 : 10 : if (opt->arg[0] == '-')
1720 : 2 : cpp_unassert (parse_in, opt->arg + 1);
1721 : : else
1722 : 8 : cpp_assert (parse_in, opt->arg);
1723 : : }
1724 : :
1725 : 181044 : if (UNLIKELY (flag_hardened)
1726 : 83 : && (opt->code == OPT_D || opt->code == OPT_U))
1727 : : {
1728 : 83 : if (!fortify_seen_p)
1729 : 79 : fortify_seen_p
1730 : 79 : = (!strncmp (opt->arg, "_FORTIFY_SOURCE", 15)
1731 : 79 : && (opt->arg[15] == '\0' || opt->arg[15] == '='));
1732 : 83 : if (!cxx_assert_seen_p)
1733 : 83 : cxx_assert_seen_p
1734 : 83 : = (!strncmp (opt->arg, "_GLIBCXX_ASSERTIONS", 19)
1735 : 83 : && (opt->arg[19] == '\0' || opt->arg[19] == '='));
1736 : : }
1737 : : }
1738 : :
1739 : 210467 : if (flag_hardened)
1740 : : {
1741 : 91 : if (!fortify_seen_p && optimize > 0)
1742 : 71 : cpp_define_formatted (parse_in, "_FORTIFY_SOURCE=%u",
1743 : 71 : targetm.fortify_source_default_level ());
1744 : 20 : else if (optimize == 0)
1745 : 20 : warning_at (UNKNOWN_LOCATION, OPT_Whardened,
1746 : : "%<_FORTIFY_SOURCE%> is not enabled by %<-fhardened%> "
1747 : : "because optimizations are turned off");
1748 : : else
1749 : 0 : warning_at (UNKNOWN_LOCATION, OPT_Whardened,
1750 : : "%<_FORTIFY_SOURCE%> is not enabled by %<-fhardened%> "
1751 : : "because it was specified in %<-D%> or %<-U%>");
1752 : 91 : if (!cxx_assert_seen_p)
1753 : 87 : cpp_define (parse_in, "_GLIBCXX_ASSERTIONS");
1754 : : else
1755 : 4 : warning_at (UNKNOWN_LOCATION, OPT_Whardened,
1756 : : "%<_GLIBCXX_ASSERTIONS%> is not enabled by "
1757 : : "%<-fhardened%> because it was specified in %<-D%> "
1758 : : "or %<-U%>");
1759 : : }
1760 : :
1761 : 210467 : cpp_stop_forcing_token_locations (parse_in);
1762 : : }
1763 : 527 : else if (cpp_opts->directives_only)
1764 : 41 : cpp_init_special_builtins (parse_in);
1765 : :
1766 : : /* Start the main input file, if the debug writer wants it. */
1767 : 210994 : if (debug_hooks->start_end_main_source_file
1768 : 42805 : && !flag_preprocess_only)
1769 : 40501 : (*debug_hooks->start_source_file) (0, this_input_filename);
1770 : :
1771 : 210994 : if (!cpp_opts->preprocessed)
1772 : : /* Handle -imacros after -D and -U. */
1773 : 391511 : for (size_t i = 0; i < deferred_count; i++)
1774 : : {
1775 : 181044 : struct deferred_opt *opt = &deferred_opts[i];
1776 : :
1777 : 181044 : if (opt->code == OPT_imacros
1778 : 181044 : && cpp_push_include (parse_in, opt->arg))
1779 : : {
1780 : : /* Disable push_command_line_include callback for now. */
1781 : 8 : include_cursor = deferred_count + 1;
1782 : 8 : cpp_scan_nooutput (parse_in);
1783 : : }
1784 : : }
1785 : :
1786 : 210994 : include_cursor = 0;
1787 : 210994 : push_command_line_include ();
1788 : 210994 : }
1789 : :
1790 : : /* Give CPP the next file given by -include, if any. */
1791 : : static void
1792 : 745191 : push_command_line_include (void)
1793 : : {
1794 : : /* This can happen if disabled by -imacros for example.
1795 : : Punt so that we don't set "<command-line>" as the filename for
1796 : : the header. */
1797 : 745191 : if (include_cursor > deferred_count)
1798 : : return;
1799 : :
1800 : 431539 : if (!done_preinclude)
1801 : : {
1802 : 210994 : done_preinclude = true;
1803 : 210994 : if (flag_hosted && std_inc && !cpp_opts->preprocessed)
1804 : : {
1805 : 210385 : const char *preinc = targetcm.c_preinclude ();
1806 : 210385 : if (preinc && cpp_push_default_include (parse_in, preinc))
1807 : : return;
1808 : : }
1809 : : }
1810 : :
1811 : 221154 : pch_cpp_save_state ();
1812 : :
1813 : 613243 : while (include_cursor < deferred_count)
1814 : : {
1815 : 181096 : struct deferred_opt *opt = &deferred_opts[include_cursor++];
1816 : :
1817 : 362139 : if (!cpp_opts->preprocessed && opt->code == OPT_include
1818 : 191260 : && cpp_push_include (parse_in, opt->arg))
1819 : : return;
1820 : : }
1821 : :
1822 : 210993 : if (include_cursor == deferred_count)
1823 : : {
1824 : 210993 : include_cursor++;
1825 : : /* -Wunused-macros should only warn about macros defined hereafter. */
1826 : 210993 : cpp_opts->warn_unused_macros = cpp_warn_unused_macros;
1827 : : /* Restore the line map back to the main file. */
1828 : 210993 : if (!cpp_opts->preprocessed)
1829 : : {
1830 : 210466 : cpp_change_file (parse_in, LC_RENAME, this_input_filename);
1831 : 210466 : if (lang_hooks.preprocess_main_file)
1832 : : /* We're starting the main file. Inform the FE of that. */
1833 : 97021 : lang_hooks.preprocess_main_file
1834 : 97021 : (parse_in, line_table, LINEMAPS_LAST_ORDINARY_MAP (line_table));
1835 : : }
1836 : :
1837 : : /* Set this here so the client can change the option if it wishes,
1838 : : and after stacking the main file so we don't trace the main file. */
1839 : 210993 : line_table->trace_includes = cpp_opts->print_include_names;
1840 : : }
1841 : : }
1842 : :
1843 : : /* File change callback. Has to handle -include files. */
1844 : : static void
1845 : 20272973 : cb_file_change (cpp_reader *reader, const line_map_ordinary *new_map)
1846 : : {
1847 : 20272973 : if (flag_preprocess_only)
1848 : 155705 : pp_file_change (new_map);
1849 : : else
1850 : 20117268 : fe_file_change (new_map);
1851 : :
1852 : 20062375 : if (new_map && cpp_opts->preprocessed
1853 : 37825 : && lang_hooks.preprocess_main_file && MAIN_FILE_P (new_map)
1854 : 20275537 : && ORDINARY_MAP_STARTING_LINE_NUMBER (new_map))
1855 : : /* We're starting the main file. Inform the FE of that. */
1856 : 450 : lang_hooks.preprocess_main_file (reader, line_table, new_map);
1857 : :
1858 : 20272973 : if (new_map
1859 : 20062375 : && (new_map->reason == LC_ENTER || new_map->reason == LC_RENAME))
1860 : : {
1861 : : /* Signal to plugins that a file is included. This could happen
1862 : : several times with the same file path, e.g. because of
1863 : : several '#include' or '#line' directives... */
1864 : 10456343 : invoke_plugin_callbacks
1865 : 10456343 : (PLUGIN_INCLUDE_FILE,
1866 : 10456343 : const_cast<char*> (ORDINARY_MAP_FILE_NAME (new_map)));
1867 : : }
1868 : :
1869 : 20062375 : if (new_map == 0 || (new_map->reason == LC_LEAVE && MAIN_FILE_P (new_map)))
1870 : : {
1871 : 534197 : pch_cpp_save_state ();
1872 : 534197 : push_command_line_include ();
1873 : : }
1874 : 20272972 : }
1875 : :
1876 : : void
1877 : 53 : cb_dir_change (cpp_reader * ARG_UNUSED (pfile), const char *dir)
1878 : : {
1879 : 53 : if (!set_src_pwd (dir))
1880 : 0 : warning (0, "too late for # directive to set debug directory");
1881 : 53 : }
1882 : :
1883 : : /* Set the C 89 standard (with 1994 amendments if C94, without GNU
1884 : : extensions if ISO). There is no concept of gnu94. */
1885 : : static void
1886 : 6947 : set_std_c89 (int c94, int iso)
1887 : : {
1888 : 9899 : cpp_set_lang (parse_in, c94 ? CLK_STDC94 : iso ? CLK_STDC89 : CLK_GNUC89);
1889 : 6947 : flag_iso = iso;
1890 : 6947 : flag_no_asm = iso;
1891 : 6947 : flag_no_gnu_keywords = iso;
1892 : 6947 : flag_no_nonansi_builtin = iso;
1893 : 6947 : flag_isoc94 = c94;
1894 : 6947 : flag_isoc99 = 0;
1895 : 6947 : flag_isoc11 = 0;
1896 : 6947 : flag_isoc23 = 0;
1897 : 6947 : flag_isoc2y = 0;
1898 : 6947 : lang_hooks.name = "GNU C89";
1899 : 6947 : }
1900 : :
1901 : : /* Set the C 99 standard (without GNU extensions if ISO). */
1902 : : static void
1903 : 1188 : set_std_c99 (int iso)
1904 : : {
1905 : 1804 : cpp_set_lang (parse_in, iso ? CLK_STDC99 : CLK_GNUC99);
1906 : 1188 : flag_no_asm = iso;
1907 : 1188 : flag_no_nonansi_builtin = iso;
1908 : 1188 : flag_iso = iso;
1909 : 1188 : flag_isoc2y = 0;
1910 : 1188 : flag_isoc23 = 0;
1911 : 1188 : flag_isoc11 = 0;
1912 : 1188 : flag_isoc99 = 1;
1913 : 1188 : flag_isoc94 = 1;
1914 : 1188 : lang_hooks.name = "GNU C99";
1915 : 1188 : }
1916 : :
1917 : : /* Set the C 11 standard (without GNU extensions if ISO). */
1918 : : static void
1919 : 4206 : set_std_c11 (int iso)
1920 : : {
1921 : 7900 : cpp_set_lang (parse_in, iso ? CLK_STDC11 : CLK_GNUC11);
1922 : 4206 : flag_no_asm = iso;
1923 : 4206 : flag_no_nonansi_builtin = iso;
1924 : 4206 : flag_iso = iso;
1925 : 4206 : flag_isoc2y = 0;
1926 : 4206 : flag_isoc23 = 0;
1927 : 4206 : flag_isoc11 = 1;
1928 : 4206 : flag_isoc99 = 1;
1929 : 4206 : flag_isoc94 = 1;
1930 : 4206 : lang_hooks.name = "GNU C11";
1931 : 4206 : }
1932 : :
1933 : : /* Set the C 17 standard (without GNU extensions if ISO). */
1934 : : static void
1935 : 826 : set_std_c17 (int iso)
1936 : : {
1937 : 1610 : cpp_set_lang (parse_in, iso ? CLK_STDC17 : CLK_GNUC17);
1938 : 826 : flag_no_asm = iso;
1939 : 826 : flag_no_nonansi_builtin = iso;
1940 : 826 : flag_iso = iso;
1941 : 826 : flag_isoc2y = 0;
1942 : 826 : flag_isoc23 = 0;
1943 : 826 : flag_isoc11 = 1;
1944 : 826 : flag_isoc99 = 1;
1945 : 826 : flag_isoc94 = 1;
1946 : 826 : lang_hooks.name = "GNU C17";
1947 : 826 : }
1948 : :
1949 : : /* Set the C 23 standard (without GNU extensions if ISO). */
1950 : : static void
1951 : 115096 : set_std_c23 (int iso)
1952 : : {
1953 : 229339 : cpp_set_lang (parse_in, iso ? CLK_STDC23 : CLK_GNUC23);
1954 : 115096 : flag_no_asm = iso;
1955 : 115096 : flag_no_nonansi_builtin = iso;
1956 : 115096 : flag_iso = iso;
1957 : 115096 : flag_isoc2y = 0;
1958 : 115096 : flag_isoc23 = 1;
1959 : 115096 : flag_isoc11 = 1;
1960 : 115096 : flag_isoc99 = 1;
1961 : 115096 : flag_isoc94 = 1;
1962 : 115096 : lang_hooks.name = "GNU C23";
1963 : 115096 : }
1964 : :
1965 : : /* Set the C 2Y standard (without GNU extensions if ISO). */
1966 : : static void
1967 : 188 : set_std_c2y (int iso)
1968 : : {
1969 : 199 : cpp_set_lang (parse_in, iso ? CLK_STDC2Y : CLK_GNUC2Y);
1970 : 188 : flag_no_asm = iso;
1971 : 188 : flag_no_nonansi_builtin = iso;
1972 : 188 : flag_iso = iso;
1973 : 188 : flag_isoc2y = 1;
1974 : 188 : flag_isoc23 = 1;
1975 : 188 : flag_isoc11 = 1;
1976 : 188 : flag_isoc99 = 1;
1977 : 188 : flag_isoc94 = 1;
1978 : 188 : lang_hooks.name = "GNU C2Y";
1979 : 188 : }
1980 : :
1981 : :
1982 : : /* Set the C++ 98 standard (without GNU extensions if ISO). */
1983 : : static void
1984 : 14147 : set_std_cxx98 (int iso)
1985 : : {
1986 : 19482 : cpp_set_lang (parse_in, iso ? CLK_CXX98 : CLK_GNUCXX);
1987 : 14147 : flag_no_gnu_keywords = iso;
1988 : 14147 : flag_no_nonansi_builtin = iso;
1989 : 14147 : flag_iso = iso;
1990 : 14147 : flag_isoc94 = 0;
1991 : 14147 : flag_isoc99 = 0;
1992 : 14147 : cxx_dialect = cxx98;
1993 : 14147 : lang_hooks.name = "GNU C++98";
1994 : 14147 : }
1995 : :
1996 : : /* Set the C++ 2011 standard (without GNU extensions if ISO). */
1997 : : static void
1998 : 5616 : set_std_cxx11 (int iso)
1999 : : {
2000 : 7038 : cpp_set_lang (parse_in, iso ? CLK_CXX11 : CLK_GNUCXX11);
2001 : 5616 : flag_no_gnu_keywords = iso;
2002 : 5616 : flag_no_nonansi_builtin = iso;
2003 : 5616 : flag_iso = iso;
2004 : : /* C++11 includes the C99 standard library. */
2005 : 5616 : flag_isoc94 = 1;
2006 : 5616 : flag_isoc99 = 1;
2007 : 5616 : cxx_dialect = cxx11;
2008 : 5616 : lang_hooks.name = "GNU C++11";
2009 : 5616 : }
2010 : :
2011 : : /* Set the C++ 2014 standard (without GNU extensions if ISO). */
2012 : : static void
2013 : 1278 : set_std_cxx14 (int iso)
2014 : : {
2015 : 1547 : cpp_set_lang (parse_in, iso ? CLK_CXX14 : CLK_GNUCXX14);
2016 : 1278 : flag_no_gnu_keywords = iso;
2017 : 1278 : flag_no_nonansi_builtin = iso;
2018 : 1278 : flag_iso = iso;
2019 : : /* C++14 includes the C99 standard library. */
2020 : 1278 : flag_isoc94 = 1;
2021 : 1278 : flag_isoc99 = 1;
2022 : 1278 : cxx_dialect = cxx14;
2023 : 1278 : lang_hooks.name = "GNU C++14";
2024 : 1278 : }
2025 : :
2026 : : /* Set the C++ 2017 standard (without GNU extensions if ISO). */
2027 : : static void
2028 : 11960 : set_std_cxx17 (int iso)
2029 : : {
2030 : 20697 : cpp_set_lang (parse_in, iso ? CLK_CXX17 : CLK_GNUCXX17);
2031 : 11960 : flag_no_gnu_keywords = iso;
2032 : 11960 : flag_no_nonansi_builtin = iso;
2033 : 11960 : flag_iso = iso;
2034 : : /* C++17 includes the C11 standard library. */
2035 : 11960 : flag_isoc94 = 1;
2036 : 11960 : flag_isoc99 = 1;
2037 : 11960 : flag_isoc11 = 1;
2038 : 11960 : cxx_dialect = cxx17;
2039 : 11960 : lang_hooks.name = "GNU C++17";
2040 : 11960 : }
2041 : :
2042 : : /* Set the C++ 2020 standard (without GNU extensions if ISO). */
2043 : : static void
2044 : 121277 : set_std_cxx20 (int iso)
2045 : : {
2046 : 226103 : cpp_set_lang (parse_in, iso ? CLK_CXX20 : CLK_GNUCXX20);
2047 : 121277 : flag_no_gnu_keywords = iso;
2048 : 121277 : flag_no_nonansi_builtin = iso;
2049 : 121277 : flag_iso = iso;
2050 : : /* C++20 includes the C11 standard library. */
2051 : 121277 : flag_isoc94 = 1;
2052 : 121277 : flag_isoc99 = 1;
2053 : 121277 : flag_isoc11 = 1;
2054 : 121277 : cxx_dialect = cxx20;
2055 : 121277 : lang_hooks.name = "GNU C++20";
2056 : 121277 : }
2057 : :
2058 : : /* Set the C++ 2023 standard (without GNU extensions if ISO). */
2059 : : static void
2060 : 1963 : set_std_cxx23 (int iso)
2061 : : {
2062 : 2488 : cpp_set_lang (parse_in, iso ? CLK_CXX23 : CLK_GNUCXX23);
2063 : 1963 : flag_no_gnu_keywords = iso;
2064 : 1963 : flag_no_nonansi_builtin = iso;
2065 : 1963 : flag_iso = iso;
2066 : : /* C++23 includes the C11 standard library. */
2067 : 1963 : flag_isoc94 = 1;
2068 : 1963 : flag_isoc99 = 1;
2069 : 1963 : flag_isoc11 = 1;
2070 : 1963 : cxx_dialect = cxx23;
2071 : 1963 : lang_hooks.name = "GNU C++23";
2072 : 1963 : }
2073 : :
2074 : : /* Set the C++ 2026 standard (without GNU extensions if ISO). */
2075 : : static void
2076 : 23816 : set_std_cxx26 (int iso)
2077 : : {
2078 : 31661 : cpp_set_lang (parse_in, iso ? CLK_CXX26 : CLK_GNUCXX26);
2079 : 23816 : flag_no_gnu_keywords = iso;
2080 : 23816 : flag_no_nonansi_builtin = iso;
2081 : 23816 : flag_iso = iso;
2082 : : /* C++26 includes the C11 standard library. */
2083 : 23816 : flag_isoc94 = 1;
2084 : 23816 : flag_isoc99 = 1;
2085 : 23816 : flag_isoc11 = 1;
2086 : 23816 : cxx_dialect = cxx26;
2087 : 23816 : lang_hooks.name = "GNU C++26";
2088 : 23816 : }
2089 : :
2090 : : /* Args to -d specify what to dump. Silently ignore
2091 : : unrecognized options; they may be aimed at toplev.cc. */
2092 : : static void
2093 : 1637 : handle_OPT_d (const char *arg)
2094 : : {
2095 : 1637 : char c;
2096 : :
2097 : 3274 : while ((c = *arg++) != '\0')
2098 : 1637 : switch (c)
2099 : : {
2100 : 796 : case 'M': /* Dump macros only. */
2101 : 796 : case 'N': /* Dump names. */
2102 : 796 : case 'D': /* Dump definitions. */
2103 : 796 : case 'U': /* Dump used macros. */
2104 : 796 : flag_dump_macros = c;
2105 : 796 : break;
2106 : :
2107 : 2 : case 'I':
2108 : 2 : flag_dump_includes = 1;
2109 : 2 : break;
2110 : : }
2111 : 1637 : }
|