1 /* Command line option handling.
2 Copyright (C) 2002, 2003 Free Software Foundation, Inc.
3 Contributed by Neil Booth.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
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
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 #include "coretypes.h"
31 #include "langhooks.h"
37 #include "diagnostic.h"
38 #include "tm_p.h" /* For OPTIMIZATION_OPTIONS. */
39 #include "insn-attr.h" /* For INSN_SCHEDULING. */
41 /* Value of the -G xx switch, and whether it was passed or not. */
42 unsigned HOST_WIDE_INT g_switch_value;
45 /* True if we should exit after parsing options. */
46 bool exit_after_options;
51 /* Print various extra warnings. -W/-Wextra. */
54 /* Don't print warning messages. -w. */
55 bool inhibit_warnings;
57 /* Treat warnings as errors. -Werror. */
58 bool warnings_are_errors;
60 /* Warn if a function returns an aggregate, since there are often
61 incompatible calling conventions for doing this. */
62 bool warn_aggregate_return;
64 /* Nonzero means warn about pointer casts that increase the required
65 alignment of the target type (and might therefore lead to a crash
66 due to a misaligned access). */
69 /* Nonzero means warn about uses of __attribute__((deprecated))
71 bool warn_deprecated_decl = true;
73 /* Warn when an optimization pass is disabled. */
74 bool warn_disabled_optimization;
76 /* Nonzero means warn if inline function is too large. */
79 /* True to warn about any objects definitions whose size is larger
80 than N bytes. Also want about function definitions whose returned
81 values are larger than N bytes, where N is `larger_than_size'. */
82 bool warn_larger_than;
83 HOST_WIDE_INT larger_than_size;
85 /* Warn about functions which might be candidates for attribute noreturn. */
86 bool warn_missing_noreturn;
88 /* True to warn about code which is never reached. */
91 /* Warn if packed attribute on struct is unnecessary and inefficient. */
94 /* Warn when gcc pads a structure to an alignment boundary. */
97 /* True means warn about all declarations which shadow others. */
100 /* Nonzero means warn about constructs which might not be
101 strict-aliasing safe. */
102 bool warn_strict_aliasing;
104 /* True to warn if a switch on an enum, that does not have a default
105 case, fails to have a case for every enum value. */
108 /* Warn if a switch does not have a default case. */
109 bool warn_switch_default;
111 /* Warn if a switch on an enum fails to have a case for every enum
112 value (regardless of the presence or otherwise of a default case). */
113 bool warn_switch_enum;
115 /* Don't suppress warnings from system headers. -Wsystem-headers. */
116 bool warn_system_headers;
118 /* True to warn about variables used before they are initialized. */
119 int warn_uninitialized;
121 /* True to warn about unused variables, functions et.al. */
122 bool warn_unused_function;
123 bool warn_unused_label;
124 bool warn_unused_parameter;
125 bool warn_unused_variable;
126 bool warn_unused_value;
128 /* Hack for cooperation between set_Wunused and set_Wextra. */
129 static bool maybe_warn_unused_parameter;
131 /* Columns of --help display. */
132 static unsigned int columns = 80;
134 /* What to print when a switch has no documentation. */
135 static const char undocumented_msg[] = N_("This switch lacks documentation");
137 /* Input file names. */
138 const char **in_fnames;
139 unsigned num_in_fnames;
141 static size_t find_opt (const char *, int);
142 static int common_handle_option (size_t scode, const char *arg, int value);
143 static void handle_param (const char *);
144 static void set_Wextra (int);
145 static unsigned int handle_option (const char **argv, unsigned int lang_mask);
146 static char *write_langs (unsigned int lang_mask);
147 static void complain_wrong_lang (const char *, const struct cl_option *,
148 unsigned int lang_mask);
149 static void handle_options (unsigned int, const char **, unsigned int);
150 static void wrap_help (const char *help, const char *item, unsigned int);
151 static void print_help (void);
152 static void print_param_help (void);
153 static void print_filtered_help (unsigned int flag);
154 static unsigned int print_switch (const char *text, unsigned int indent);
156 /* Perform a binary search to find which option the command-line INPUT
157 matches. Returns its index in the option array, and N_OPTS
158 (cl_options_count) on failure.
160 This routine is quite subtle. A normal binary search is not good
161 enough because some options can be suffixed with an argument, and
162 multiple sub-matches can occur, e.g. input of "-pedantic" matching
163 the initial substring of "-pedantic-errors".
165 A more complicated example is -gstabs. It should match "-g" with
166 an argument of "stabs". Suppose, however, that the number and list
167 of switches are such that the binary search tests "-gen-decls"
168 before having tested "-g". This doesn't match, and as "-gen-decls"
169 is less than "-gstabs", it will become the lower bound of the
170 binary search range, and "-g" will never be seen. To resolve this
171 issue, opts.sh makes "-gen-decls" point, via the back_chain member,
172 to "-g" so that failed searches that end between "-gen-decls" and
173 the lexicographically subsequent switch know to go back and see if
174 "-g" causes a match (which it does in this example).
176 This search is done in such a way that the longest match for the
177 front end in question wins. If there is no match for the current
178 front end, the longest match for a different front end is returned
179 (or N_OPTS if none) and the caller emits an error message. */
181 find_opt (const char *input, int lang_mask)
183 size_t mn, mx, md, opt_len;
184 size_t match_wrong_lang;
188 mx = cl_options_count;
190 /* Find mn such this lexicographical inequality holds:
191 cl_options[mn] <= input < cl_options[mn + 1]. */
195 opt_len = cl_options[md].opt_len;
196 comp = strncmp (input, cl_options[md].opt_text + 1, opt_len);
204 /* This is the switch that is the best match but for a different
205 front end, or cl_options_count if there is no match at all. */
206 match_wrong_lang = cl_options_count;
208 /* Backtrace the chain of possible matches, returning the longest
209 one, if any, that fits best. With current GCC switches, this
210 loop executes at most twice. */
213 const struct cl_option *opt = &cl_options[mn];
215 /* Is this switch a prefix of the input? */
216 if (!strncmp (input, opt->opt_text + 1, opt->opt_len))
218 /* If language is OK, and the match is exact or the switch
219 takes a joined argument, return it. */
220 if ((opt->flags & lang_mask)
221 && (input[opt->opt_len] == '\0' || (opt->flags & CL_JOINED)))
224 /* If we haven't remembered a prior match, remember this
225 one. Any prior match is necessarily better. */
226 if (match_wrong_lang == cl_options_count)
227 match_wrong_lang = mn;
230 /* Try the next possibility. This is cl_options_count if there
232 mn = opt->back_chain;
234 while (mn != cl_options_count);
236 /* Return the best wrong match, or cl_options_count if none. */
237 return match_wrong_lang;
240 /* If ARG is a non-negative integer made up solely of digits, return its
241 value, otherwise return -1. */
243 integral_argument (const char *arg)
247 while (*p && ISDIGIT (*p))
256 /* Return a malloced slash-separated list of languages in MASK. */
258 write_langs (unsigned int mask)
260 unsigned int n = 0, len = 0;
261 const char *lang_name;
264 for (n = 0; (lang_name = lang_names[n]) != 0; n++)
265 if (mask & (1U << n))
266 len += strlen (lang_name) + 1;
268 result = xmalloc (len);
270 for (n = 0; (lang_name = lang_names[n]) != 0; n++)
271 if (mask & (1U << n))
275 strcpy (result + len, lang_name);
276 len += strlen (lang_name);
284 /* Complain that switch OPT_INDEX does not apply to this front end. */
286 complain_wrong_lang (const char *text, const struct cl_option *option,
287 unsigned int lang_mask)
289 char *ok_langs, *bad_lang;
291 ok_langs = write_langs (option->flags);
292 bad_lang = write_langs (lang_mask);
294 /* Eventually this should become a hard error IMO. */
295 warning ("command line option \"%s\" is valid for %s but not for %s",
296 text, ok_langs, bad_lang);
302 /* Handle the switch beginning at ARGV for the language indicated by
303 LANG_MASK. Returns the number of switches consumed. */
305 handle_option (const char **argv, unsigned int lang_mask)
308 const char *opt, *arg = 0;
311 unsigned int result = 0;
312 const struct cl_option *option;
316 /* Drop the "no-" from negative switches. */
317 if ((opt[1] == 'W' || opt[1] == 'f')
318 && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
320 size_t len = strlen (opt) - 3;
322 dup = xmalloc (len + 1);
325 memcpy (dup + 2, opt + 5, len - 2 + 1);
330 opt_index = find_opt (opt + 1, lang_mask | CL_COMMON);
331 if (opt_index == cl_options_count)
334 option = &cl_options[opt_index];
336 /* Reject negative form of switches that don't take negatives as
338 if (!value && (option->flags & CL_REJECT_NEGATIVE))
341 /* We've recognized this switch. */
344 /* Sort out any argument the switch takes. */
345 if (option->flags & CL_JOINED)
347 /* Have arg point to the original switch. This is because
348 some code, such as disable_builtin_function, expects its
349 argument to be persistent until the program exits. */
350 arg = argv[0] + cl_options[opt_index].opt_len + 1;
352 arg += strlen ("no-");
354 if (*arg == '\0' && !(option->flags & CL_MISSING_OK))
356 if (option->flags & CL_SEPARATE)
362 /* Missing argument. */
366 else if (option->flags & CL_SEPARATE)
372 /* Now we've swallowed any potential argument, complain if this
373 is a switch for a different front end. */
374 if (!(option->flags & (lang_mask | CL_COMMON)))
376 complain_wrong_lang (argv[0], option, lang_mask);
380 if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE)))
382 if (!(*lang_hooks.missing_argument) (opt, opt_index))
383 error ("missing argument to \"%s\"", opt);
387 /* If the switch takes an integer, convert it. */
388 if (arg && (option->flags & CL_UINTEGER))
390 value = integral_argument (arg);
393 error ("argument to \"%s\" should be a non-negative integer",
399 if (option->flags & lang_mask)
400 if ((*lang_hooks.handle_option) (opt_index, arg, value) == 0)
403 if (result && (option->flags & CL_COMMON))
404 if (common_handle_option (opt_index, arg, value) == 0)
413 /* Decode and handle the vector of command line options. LANG_MASK
414 contains has a single bit set representing the current
417 handle_options (unsigned int argc, const char **argv, unsigned int lang_mask)
421 for (i = 1; i < argc; i += n)
423 const char *opt = argv[i];
425 /* Interpret "-" or a non-switch as a file name. */
426 if (opt[0] != '-' || opt[1] == '\0')
428 main_input_filename = opt;
429 add_input_filename (opt);
434 n = handle_option (argv + i, lang_mask);
439 error ("unrecognized command line option \"%s\"", opt);
444 /* Handle FILENAME from the command line. */
446 add_input_filename (const char *filename)
449 in_fnames = xrealloc (in_fnames, num_in_fnames * sizeof (in_fnames[0]));
450 in_fnames[num_in_fnames - 1] = filename;
453 /* Parse command line options and set default flag values. Do minimal
454 options processing. */
456 decode_options (unsigned int argc, const char **argv)
458 unsigned int i, lang_mask;
460 /* Perform language-specific options initialization. */
461 lang_mask = (*lang_hooks.init_options) (argc, argv);
463 /* Scan to see what optimization level has been specified. That will
464 determine the default value of many flags. */
465 for (i = 1; i < argc; i++)
467 if (!strcmp (argv[i], "-O"))
472 else if (argv[i][0] == '-' && argv[i][1] == 'O')
474 /* Handle -Os, -O2, -O3, -O69, ... */
475 const char *p = &argv[i][2];
477 if ((p[0] == 's') && (p[1] == 0))
481 /* Optimizing for size forces optimize to be 2. */
486 const int optimize_val = read_integral_parameter (p, p - 2, -1);
487 if (optimize_val != -1)
489 optimize = optimize_val;
498 flag_merge_constants = 0;
504 flag_thread_jumps = 1;
506 flag_delayed_branch = 1;
508 #ifdef CAN_DEBUG_WITHOUT_FP
509 flag_omit_frame_pointer = 1;
511 flag_guess_branch_prob = 1;
512 flag_cprop_registers = 1;
513 flag_loop_optimize = 1;
514 flag_crossjumping = 1;
515 flag_if_conversion = 1;
516 flag_if_conversion2 = 1;
521 flag_optimize_sibling_calls = 1;
522 flag_cse_follow_jumps = 1;
523 flag_cse_skip_blocks = 1;
525 flag_expensive_optimizations = 1;
526 flag_strength_reduce = 1;
527 flag_rerun_cse_after_loop = 1;
528 flag_rerun_loop_opt = 1;
529 flag_caller_saves = 1;
532 #ifdef INSN_SCHEDULING
533 flag_schedule_insns = 1;
534 flag_schedule_insns_after_reload = 1;
537 flag_strict_aliasing = 1;
538 flag_delete_null_pointer_checks = 1;
539 flag_reorder_blocks = 1;
540 flag_reorder_functions = 1;
545 flag_inline_functions = 1;
546 flag_rename_registers = 1;
547 flag_unswitch_loops = 1;
548 flag_unit_at_a_time = 1;
551 if (optimize < 2 || optimize_size)
558 /* Don't reorder blocks when optimizing for size because extra
559 jump insns may be created; also barrier may create extra padding.
561 More correctly we should have a block reordering mode that tried
562 to minimize the combined size of all the jumps. This would more
563 or less automatically remove extra jumps, but would also try to
564 use more short jumps instead of long jumps. */
565 flag_reorder_blocks = 0;
568 /* Initialize whether `char' is signed. */
569 flag_signed_char = DEFAULT_SIGNED_CHAR;
570 #ifdef DEFAULT_SHORT_ENUMS
571 /* Initialize how much space enums occupy, by default. */
572 flag_short_enums = DEFAULT_SHORT_ENUMS;
575 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
578 set_target_switch ("");
580 /* Unwind tables are always present in an ABI-conformant IA-64
581 object file, so the default should be ON. */
582 #ifdef IA64_UNWIND_INFO
583 flag_unwind_tables = IA64_UNWIND_INFO;
586 #ifdef OPTIMIZATION_OPTIONS
587 /* Allow default optimizations to be specified on a per-machine basis. */
588 OPTIMIZATION_OPTIONS (optimize, optimize_size);
591 handle_options (argc, argv, lang_mask);
595 if (flag_pic && !flag_pie)
598 if (flag_no_inline == 2)
601 flag_really_no_inline = flag_no_inline;
603 /* Set flag_no_inline before the post_options () hook. The C front
604 ends use it to determine tree inlining defaults. FIXME: such
605 code should be lang-independent when all front ends use tree
606 inlining, in which case it, and this condition, should be moved
607 to the top of process_options() instead. */
610 /* Inlining does not work if not optimizing,
611 so force it not to be done. */
615 /* The c_decode_option function and decode_option hook set
616 this to `2' if -Wall is used, so we can avoid giving out
617 lots of errors for people who don't realize what -Wall does. */
618 if (warn_uninitialized == 1)
619 warning ("-Wuninitialized is not supported without -O");
622 if (flag_really_no_inline == 2)
623 flag_really_no_inline = flag_no_inline;
626 /* Handle target- and language-independent options. Return zero to
627 generate an "unknown option" message. */
629 common_handle_option (size_t scode, const char *arg,
630 int value ATTRIBUTE_UNUSED)
632 enum opt_code code = (enum opt_code) scode;
641 exit_after_options = true;
648 case OPT__target_help:
649 display_target_options ();
650 exit_after_options = true;
654 print_version (stderr, "");
655 exit_after_options = true;
659 g_switch_value = value;
665 /* Currently handled in a prescan. */
669 /* For backward compatibility, -W is the same as -Wextra. */
673 case OPT_Waggregate_return:
674 warn_aggregate_return = value;
677 case OPT_Wcast_align:
678 warn_cast_align = value;
681 case OPT_Wdeprecated_declarations:
682 warn_deprecated_decl = value;
685 case OPT_Wdisabled_optimization:
686 warn_disabled_optimization = value;
690 warnings_are_errors = value;
701 case OPT_Wlarger_than_:
702 larger_than_size = value;
703 warn_larger_than = value != -1;
706 case OPT_Wmissing_noreturn:
707 warn_missing_noreturn = value;
722 case OPT_Wstrict_aliasing:
723 warn_strict_aliasing = value;
730 case OPT_Wswitch_default:
731 warn_switch_default = value;
734 case OPT_Wswitch_enum:
735 warn_switch_enum = value;
738 case OPT_Wsystem_headers:
739 warn_system_headers = value;
742 case OPT_Wuninitialized:
743 warn_uninitialized = value;
746 case OPT_Wunreachable_code:
747 warn_notreached = value;
754 case OPT_Wunused_function:
755 warn_unused_function = value;
758 case OPT_Wunused_label:
759 warn_unused_label = value;
762 case OPT_Wunused_parameter:
763 warn_unused_parameter = value;
766 case OPT_Wunused_value:
767 warn_unused_value = value;
770 case OPT_Wunused_variable:
771 warn_unused_variable = value;
776 aux_info_file_name = arg;
777 flag_gen_aux_info = 1;
784 case OPT_auxbase_strip:
786 char *tmp = xstrdup (arg);
787 strip_off_ending (tmp, strlen (tmp));
794 decode_d_option (arg);
798 dump_base_name = arg;
802 flag_pic = value + value;
806 flag_pie = value + value;
809 case OPT_falign_functions:
810 align_functions = !value;
813 case OPT_falign_functions_:
814 align_functions = value;
817 case OPT_falign_jumps:
818 align_jumps = !value;
821 case OPT_falign_jumps_:
825 case OPT_falign_labels:
826 align_labels = !value;
829 case OPT_falign_labels_:
830 align_labels = value;
833 case OPT_falign_loops:
834 align_loops = !value;
837 case OPT_falign_loops_:
841 case OPT_fargument_alias:
842 flag_argument_noalias = !value;
845 case OPT_fargument_noalias:
846 flag_argument_noalias = value;
849 case OPT_fargument_noalias_global:
850 flag_argument_noalias = value + value;
853 case OPT_fasynchronous_unwind_tables:
854 flag_asynchronous_unwind_tables = value;
857 case OPT_fbounds_check:
858 flag_bounds_check = value;
861 case OPT_fbranch_count_reg:
862 flag_branch_on_count_reg = value;
865 case OPT_fbranch_probabilities:
866 flag_branch_probabilities = value;
869 case OPT_fbranch_target_load_optimize:
870 flag_branch_target_load_optimize = value;
873 case OPT_fbranch_target_load_optimize2:
874 flag_branch_target_load_optimize2 = value;
877 case OPT_fcall_used_:
878 fix_register (arg, 0, 1);
881 case OPT_fcall_saved_:
882 fix_register (arg, 0, 0);
885 case OPT_fcaller_saves:
886 flag_caller_saves = value;
890 flag_no_common = !value;
893 case OPT_fcprop_registers:
894 flag_cprop_registers = value;
897 case OPT_fcrossjumping:
898 flag_crossjumping = value;
901 case OPT_fcse_follow_jumps:
902 flag_cse_follow_jumps = value;
905 case OPT_fcse_skip_blocks:
906 flag_cse_skip_blocks = value;
909 case OPT_fdata_sections:
910 flag_data_sections = value;
914 flag_defer_pop = value;
917 case OPT_fdelayed_branch:
918 flag_delayed_branch = value;
921 case OPT_fdelete_null_pointer_checks:
922 flag_delete_null_pointer_checks = value;
925 case OPT_fdiagnostics_show_location_:
926 if (!strcmp (arg, "once"))
927 diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
928 else if (!strcmp (arg, "every-line"))
929 diagnostic_prefixing_rule (global_dc)
930 = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
935 case OPT_fdump_unnumbered:
936 flag_dump_unnumbered = value;
939 case OPT_feliminate_dwarf2_dups:
940 flag_eliminate_dwarf2_dups = value;
943 case OPT_feliminate_unused_debug_types:
944 flag_eliminate_unused_debug_types = value;
947 case OPT_feliminate_unused_debug_symbols:
948 flag_debug_only_used_symbols = value;
951 case OPT_fexceptions:
952 flag_exceptions = value;
955 case OPT_fexpensive_optimizations:
956 flag_expensive_optimizations = value;
960 set_fast_math_flags (value);
963 case OPT_ffinite_math_only:
964 flag_finite_math_only = value;
968 fix_register (arg, 1, 1);
971 case OPT_ffunction_cse:
972 flag_no_function_cse = !value;
975 case OPT_ffloat_store:
976 flag_float_store = value;
979 case OPT_fforce_addr:
980 flag_force_addr = value;
984 flag_force_mem = value;
987 case OPT_ffunction_sections:
988 flag_function_sections = value;
996 flag_gcse_lm = value;
1000 flag_gcse_sm = value;
1003 case OPT_fgnu_linker:
1004 flag_gnu_linker = value;
1007 case OPT_fguess_branch_probability:
1008 flag_guess_branch_prob = value;
1012 flag_no_ident = !value;
1015 case OPT_fif_conversion:
1016 flag_if_conversion = value;
1019 case OPT_fif_conversion2:
1020 flag_if_conversion2 = value;
1023 case OPT_finhibit_size_directive:
1024 flag_inhibit_size_directive = value;
1028 flag_no_inline = !value;
1031 case OPT_finline_functions:
1032 flag_inline_functions = value;
1035 case OPT_finline_limit_:
1036 case OPT_finline_limit_eq:
1037 set_param_value ("max-inline-insns", value);
1038 set_param_value ("max-inline-insns-single", value / 2);
1039 set_param_value ("max-inline-insns-auto", value / 2);
1040 set_param_value ("max-inline-insns-rtl", value);
1041 if (value / 4 < MIN_INLINE_INSNS)
1044 set_param_value ("min-inline-insns", value / 4);
1046 set_param_value ("min-inline-insns", 10);
1050 case OPT_finstrument_functions:
1051 flag_instrument_function_entry_exit = value;
1054 case OPT_fkeep_inline_functions:
1055 flag_keep_inline_functions =value;
1058 case OPT_fkeep_static_consts:
1059 flag_keep_static_consts = value;
1062 case OPT_fleading_underscore:
1063 flag_leading_underscore = value;
1066 case OPT_floop_optimize:
1067 flag_loop_optimize = value;
1070 case OPT_fmath_errno:
1071 flag_errno_math = value;
1074 case OPT_fmem_report:
1078 case OPT_fmerge_all_constants:
1079 flag_merge_constants = value + value;
1082 case OPT_fmerge_constants:
1083 flag_merge_constants = value;
1086 case OPT_fmessage_length_:
1087 pp_set_line_maximum_length (global_dc->printer, value);
1090 case OPT_fmove_all_movables:
1091 flag_move_all_movables = value;
1095 flag_new_regalloc = value;
1098 case OPT_fnon_call_exceptions:
1099 flag_non_call_exceptions = value;
1102 case OPT_fold_unroll_all_loops:
1103 flag_old_unroll_all_loops = value;
1106 case OPT_fold_unroll_loops:
1107 flag_old_unroll_loops = value;
1110 case OPT_fomit_frame_pointer:
1111 flag_omit_frame_pointer = value;
1114 case OPT_foptimize_register_move:
1115 flag_regmove = value;
1118 case OPT_foptimize_sibling_calls:
1119 flag_optimize_sibling_calls = value;
1122 case OPT_fpack_struct:
1123 flag_pack_struct = value;
1126 case OPT_fpeel_loops:
1127 flag_peel_loops = value;
1130 case OPT_fpcc_struct_return:
1131 flag_pcc_struct_return = value;
1135 flag_no_peephole = !value;
1138 case OPT_fpeephole2:
1139 flag_peephole2 = value;
1150 case OPT_fprefetch_loop_arrays:
1151 flag_prefetch_loop_arrays = value;
1155 profile_flag = value;
1158 case OPT_fprofile_arcs:
1159 profile_arc_flag = value;
1162 case OPT_frandom_seed:
1163 /* The real switch is -fno-random-seed. */
1166 flag_random_seed = NULL;
1169 case OPT_frandom_seed_:
1170 flag_random_seed = arg;
1173 case OPT_freduce_all_givs:
1174 flag_reduce_all_givs = value;
1177 case OPT_freg_struct_return:
1178 flag_pcc_struct_return = !value;
1182 flag_regmove = value;
1185 case OPT_frename_registers:
1186 flag_rename_registers = value;
1189 case OPT_freorder_blocks:
1190 flag_reorder_blocks = value;
1193 case OPT_freorder_functions:
1194 flag_reorder_functions = value;
1197 case OPT_frerun_cse_after_loop:
1198 flag_rerun_cse_after_loop = value;
1201 case OPT_frerun_loop_opt:
1202 flag_rerun_loop_opt = value;
1205 case OPT_fsched_interblock:
1206 flag_schedule_interblock= value;
1209 case OPT_fsched_spec:
1210 flag_schedule_speculative = value;
1213 case OPT_fsched_spec_load:
1214 flag_schedule_speculative_load = value;
1217 case OPT_fsched_spec_load_dangerous:
1218 flag_schedule_speculative_load_dangerous = value;
1221 case OPT_fsched_verbose_:
1222 #ifdef INSN_SCHEDULING
1223 fix_sched_param ("verbose", arg);
1229 case OPT_fsched2_use_superblocks:
1230 flag_sched2_use_superblocks = value;
1233 case OPT_fsched2_use_traces:
1234 flag_sched2_use_traces = value;
1237 case OPT_fschedule_insns:
1238 flag_schedule_insns = value;
1241 case OPT_fschedule_insns2:
1242 flag_schedule_insns_after_reload = value;
1245 case OPT_fshared_data:
1246 flag_shared_data = value;
1249 case OPT_fsignaling_nans:
1250 flag_signaling_nans = value;
1253 case OPT_fsingle_precision_constant:
1254 flag_single_precision_constant = value;
1262 flag_ssa_ccp = value;
1266 flag_ssa_dce = value;
1269 case OPT_fstack_check:
1270 flag_stack_check = value;
1273 case OPT_fstack_limit:
1274 /* The real switch is -fno-stack-limit. */
1277 stack_limit_rtx = NULL_RTX;
1280 case OPT_fstack_limit_register_:
1282 int reg = decode_reg_name (arg);
1284 error ("unrecognized register name \"%s\"", arg);
1286 stack_limit_rtx = gen_rtx_REG (Pmode, reg);
1290 case OPT_fstack_limit_symbol_:
1291 stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (arg));
1294 case OPT_fstrength_reduce:
1295 flag_strength_reduce = value;
1298 case OPT_fstrict_aliasing:
1299 flag_strict_aliasing = value;
1302 case OPT_fsyntax_only:
1303 flag_syntax_only = value;
1306 case OPT_ftest_coverage:
1307 flag_test_coverage = value;
1310 case OPT_fthread_jumps:
1311 flag_thread_jumps = value;
1314 case OPT_ftime_report:
1315 time_report = value;
1318 case OPT_ftls_model_:
1319 if (!strcmp (arg, "global-dynamic"))
1320 flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
1321 else if (!strcmp (arg, "local-dynamic"))
1322 flag_tls_default = TLS_MODEL_LOCAL_DYNAMIC;
1323 else if (!strcmp (arg, "initial-exec"))
1324 flag_tls_default = TLS_MODEL_INITIAL_EXEC;
1325 else if (!strcmp (arg, "local-exec"))
1326 flag_tls_default = TLS_MODEL_LOCAL_EXEC;
1328 warning ("unknown tls-model \"%s\"", arg);
1332 flag_tracer = value;
1335 case OPT_ftrapping_math:
1336 flag_trapping_math = value;
1343 case OPT_funit_at_a_time:
1344 flag_unit_at_a_time = value;
1347 case OPT_funroll_all_loops:
1348 flag_unroll_all_loops = value;
1351 case OPT_funroll_loops:
1352 flag_unroll_loops = value;
1355 case OPT_funsafe_math_optimizations:
1356 flag_unsafe_math_optimizations = value;
1359 case OPT_funswitch_loops:
1360 flag_unswitch_loops = value;
1363 case OPT_funwind_tables:
1364 flag_unwind_tables = value;
1367 case OPT_fverbose_asm:
1368 flag_verbose_asm = value;
1375 case OPT_fwritable_strings:
1376 flag_writable_strings = value;
1379 case OPT_fzero_initialized_in_bss:
1380 flag_zero_initialized_in_bss = value;
1384 decode_g_option (arg);
1388 set_target_switch (arg);
1392 asm_file_name = arg;
1403 case OPT_pedantic_errors:
1404 flag_pedantic_errors = pedantic = 1;
1416 inhibit_warnings = true;
1423 /* Handle --param NAME=VALUE. */
1425 handle_param (const char *carg)
1430 arg = xstrdup (carg);
1431 equal = strchr (arg, '=');
1433 error ("%s: --param arguments should be of the form NAME=VALUE", arg);
1436 value = integral_argument (equal + 1);
1438 error ("invalid --param value `%s'", equal + 1);
1442 set_param_value (arg, value);
1449 /* Handle -W and -Wextra. */
1451 set_Wextra (int setting)
1453 extra_warnings = setting;
1454 warn_unused_value = setting;
1455 warn_unused_parameter = (setting && maybe_warn_unused_parameter);
1457 /* We save the value of warn_uninitialized, since if they put
1458 -Wuninitialized on the command line, we need to generate a
1459 warning about not using it without also specifying -O. */
1461 warn_uninitialized = 0;
1462 else if (warn_uninitialized != 1)
1463 warn_uninitialized = 2;
1466 /* Initialize unused warning flags. */
1468 set_Wunused (int setting)
1470 warn_unused_function = setting;
1471 warn_unused_label = setting;
1472 /* Unused function parameter warnings are reported when either
1473 ``-Wextra -Wunused'' or ``-Wunused-parameter'' is specified.
1474 Thus, if -Wextra has already been seen, set warn_unused_parameter;
1475 otherwise set maybe_warn_extra_parameter, which will be picked up
1477 maybe_warn_unused_parameter = setting;
1478 warn_unused_parameter = (setting && extra_warnings);
1479 warn_unused_variable = setting;
1480 warn_unused_value = setting;
1483 /* The following routines are useful in setting all the flags that
1484 -ffast-math and -fno-fast-math imply. */
1486 set_fast_math_flags (int set)
1488 flag_trapping_math = !set;
1489 flag_unsafe_math_optimizations = set;
1490 flag_finite_math_only = set;
1491 flag_errno_math = !set;
1493 flag_signaling_nans = 0;
1496 /* Return true iff flags are set as if -ffast-math. */
1498 fast_math_flags_set_p (void)
1500 return (!flag_trapping_math
1501 && flag_unsafe_math_optimizations
1502 && flag_finite_math_only
1503 && !flag_errno_math);
1506 /* Output --help text. */
1513 GET_ENVIRONMENT (p, "COLUMNS");
1516 int value = atoi (p);
1521 puts (_("The following options are language-independent:\n"));
1523 print_filtered_help (CL_COMMON);
1524 print_param_help ();
1526 for (i = 0; lang_names[i]; i++)
1528 printf (_("The %s front end recognizes the following options:\n\n"),
1530 print_filtered_help (1U << i);
1536 /* Print the help for --param. */
1538 print_param_help (void)
1542 puts (_("The --param option recognizes the following as parameters:\n"));
1544 for (i = 0; i < LAST_PARAM; i++)
1546 const char *help = compiler_params[i].help;
1547 const char *param = compiler_params[i].option;
1549 if (help == NULL || *help == '\0')
1550 help = undocumented_msg;
1552 /* Get the translation. */
1555 wrap_help (help, param, strlen (param));
1561 /* Print help for a specific front-end, etc. */
1563 print_filtered_help (unsigned int flag)
1565 unsigned int i, len, filter, indent = 0;
1566 bool duplicates = false;
1567 const char *help, *opt, *tab;
1568 static char *printed;
1570 if (flag == CL_COMMON)
1574 printed = xmalloc (cl_options_count);
1575 memset (printed, 0, cl_options_count);
1579 /* Don't print COMMON options twice. */
1580 filter = flag | CL_COMMON;
1582 for (i = 0; i < cl_options_count; i++)
1584 if ((cl_options[i].flags & filter) != flag)
1587 /* Skip help for internal switches. */
1588 if (cl_options[i].flags & CL_UNDOCUMENTED)
1591 /* Skip switches that have already been printed, mark them to be
1596 indent = print_switch (cl_options[i].opt_text, indent);
1607 for (i = 0; i < cl_options_count; i++)
1609 if ((cl_options[i].flags & filter) != flag)
1612 /* Skip help for internal switches. */
1613 if (cl_options[i].flags & CL_UNDOCUMENTED)
1616 /* Skip switches that have already been printed. */
1622 help = cl_options[i].help;
1624 help = undocumented_msg;
1626 /* Get the translation. */
1629 tab = strchr (help, '\t');
1638 opt = cl_options[i].opt_text;
1642 wrap_help (help, opt, len);
1648 /* Output ITEM, of length ITEM_WIDTH, in the left column, followed by
1649 word-wrapped HELP in a second column. */
1651 print_switch (const char *text, unsigned int indent)
1653 unsigned int len = strlen (text) + 1; /* trailing comma */
1658 if (indent + len > columns)
1669 fputs (text, stdout);
1671 return indent + len + 1;
1674 /* Output ITEM, of length ITEM_WIDTH, in the left column, followed by
1675 word-wrapped HELP in a second column. */
1677 wrap_help (const char *help, const char *item, unsigned int item_width)
1679 unsigned int col_width = 27;
1680 unsigned int remaining, room, len;
1682 remaining = strlen (help);
1686 room = columns - 3 - MAX (col_width, item_width);
1695 for (i = 0; help[i]; i++)
1697 if (i >= room && len != remaining)
1701 else if ((help[i] == '-' || help[i] == '/')
1702 && help[i + 1] != ' '
1703 && ISALPHA (help[i - 1]))
1708 printf( " %-*.*s %.*s\n", col_width, item_width, item, len, help);
1710 while (help[len] == ' ')