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
24 #include "coretypes.h"
30 #include "langhooks.h"
36 #include "diagnostic.h"
37 #include "tm_p.h" /* For OPTIMIZATION_OPTIONS. */
38 #include "insn-attr.h" /* For INSN_SCHEDULING. */
40 /* Value of the -G xx switch, and whether it was passed or not. */
41 unsigned HOST_WIDE_INT g_switch_value;
44 /* True if we should exit after parsing options. */
45 bool exit_after_options;
50 /* Print various extra warnings. -W/-Wextra. */
53 /* Don't print warning messages. -w. */
54 bool inhibit_warnings;
56 /* Treat warnings as errors. -Werror. */
57 bool warnings_are_errors;
59 /* Warn if a function returns an aggregate, since there are often
60 incompatible calling conventions for doing this. */
61 bool warn_aggregate_return;
63 /* Nonzero means warn about pointer casts that increase the required
64 alignment of the target type (and might therefore lead to a crash
65 due to a misaligned access). */
68 /* Nonzero means warn about uses of __attribute__((deprecated))
70 bool warn_deprecated_decl = true;
72 /* Warn when an optimization pass is disabled. */
73 bool warn_disabled_optimization;
75 /* Nonzero means warn if inline function is too large. */
78 /* True to warn about any objects definitions whose size is larger
79 than N bytes. Also want about function definitions whose returned
80 values are larger than N bytes, where N is `larger_than_size'. */
81 bool warn_larger_than;
82 HOST_WIDE_INT larger_than_size;
84 /* Warn about functions which might be candidates for attribute noreturn. */
85 bool warn_missing_noreturn;
87 /* True to warn about code which is never reached. */
90 /* Warn if packed attribute on struct is unnecessary and inefficient. */
93 /* Warn when gcc pads a structure to an alignment boundary. */
96 /* True means warn about all declarations which shadow others. */
99 /* Nonzero means warn about constructs which might not be
100 strict-aliasing safe. */
101 bool warn_strict_aliasing;
103 /* True to warn if a switch on an enum, that does not have a default
104 case, fails to have a case for every enum value. */
107 /* Warn if a switch does not have a default case. */
108 bool warn_switch_default;
110 /* Warn if a switch on an enum fails to have a case for every enum
111 value (regardless of the presence or otherwise of a default case). */
112 bool warn_switch_enum;
114 /* Don't suppress warnings from system headers. -Wsystem-headers. */
115 bool warn_system_headers;
117 /* True to warn about variables used before they are initialized. */
118 int warn_uninitialized;
120 /* True to warn about unused variables, functions et.al. */
121 bool warn_unused_function;
122 bool warn_unused_label;
123 bool warn_unused_parameter;
124 bool warn_unused_variable;
125 bool warn_unused_value;
127 /* Hack for cooperation between set_Wunused and set_Wextra. */
128 static bool maybe_warn_unused_parameter;
130 static size_t find_opt (const char *, int);
131 static int common_handle_option (size_t scode, const char *arg, int value);
132 static void handle_param (const char *);
133 static void set_Wextra (int);
134 static unsigned int handle_option (char **argv, unsigned int lang_mask);
135 static char *write_langs (unsigned int lang_mask);
136 static void complain_wrong_lang (const char *, const struct cl_option *,
137 unsigned int lang_mask);
138 static void handle_options (unsigned int, char **, unsigned int lang_mask);
140 /* Perform a binary search to find which option the command-line INPUT
141 matches. Returns its index in the option array, and N_OPTS
142 (cl_options_count) on failure.
144 This routine is quite subtle. A normal binary search is not good
145 enough because some options can be suffixed with an argument, and
146 multiple sub-matches can occur, e.g. input of "-pedantic" matching
147 the initial substring of "-pedantic-errors".
149 A more complicated example is -gstabs. It should match "-g" with
150 an argument of "stabs". Suppose, however, that the number and list
151 of switches are such that the binary search tests "-gen-decls"
152 before having tested "-g". This doesn't match, and as "-gen-decls"
153 is less than "-gstabs", it will become the lower bound of the
154 binary search range, and "-g" will never be seen. To resolve this
155 issue, opts.sh makes "-gen-decls" point, via the back_chain member,
156 to "-g" so that failed searches that end between "-gen-decls" and
157 the lexicographically subsequent switch know to go back and see if
158 "-g" causes a match (which it does in this example).
160 This search is done in such a way that the longest match for the
161 front end in question wins. If there is no match for the current
162 front end, the longest match for a different front end is returned
163 (or N_OPTS if none) and the caller emits an error message. */
165 find_opt (const char *input, int lang_mask)
167 size_t mn, mx, md, opt_len;
168 size_t match_wrong_lang;
172 mx = cl_options_count;
174 /* Find mn such this lexicographical inequality holds:
175 cl_options[mn] <= input < cl_options[mn + 1]. */
179 opt_len = cl_options[md].opt_len;
180 comp = strncmp (input, cl_options[md].opt_text, opt_len);
188 /* This is the switch that is the best match but for a different
189 front end, or cl_options_count if there is no match at all. */
190 match_wrong_lang = cl_options_count;
192 /* Backtrace the chain of possible matches, returning the longest
193 one, if any, that fits best. With current GCC switches, this
194 loop executes at most twice. */
197 const struct cl_option *opt = &cl_options[mn];
199 /* Is this switch a prefix of the input? */
200 if (!strncmp (input, opt->opt_text, opt->opt_len))
202 /* If language is OK, and the match is exact or the switch
203 takes a joined argument, return it. */
204 if ((opt->flags & lang_mask)
205 && (input[opt->opt_len] == '\0' || (opt->flags & CL_JOINED)))
208 /* If we haven't remembered a prior match, remember this
209 one. Any prior match is necessarily better. */
210 if (match_wrong_lang == cl_options_count)
211 match_wrong_lang = mn;
214 /* Try the next possibility. This is cl_options_count if there
216 mn = opt->back_chain;
218 while (mn != cl_options_count);
220 /* Return the best wrong match, or cl_options_count if none. */
221 return match_wrong_lang;
224 /* If ARG is a non-negative integer made up solely of digits, return its
225 value, otherwise return -1. */
227 integral_argument (const char *arg)
231 while (*p && ISDIGIT (*p))
240 /* Return a malloced slash-separated list of languages in MASK. */
242 write_langs (unsigned int mask)
244 unsigned int n = 0, len = 0;
245 const char *lang_name;
248 for (n = 0; (lang_name = lang_names[n]) != 0; n++)
249 if (mask & (1U << n))
250 len += strlen (lang_name) + 1;
252 result = xmalloc (len);
254 for (n = 0; (lang_name = lang_names[n]) != 0; n++)
255 if (mask & (1U << n))
259 strcpy (result + len, lang_name);
260 len += strlen (lang_name);
268 /* Complain that switch OPT_INDEX does not apply to this front end. */
270 complain_wrong_lang (const char *text, const struct cl_option *option,
271 unsigned int lang_mask)
273 char *ok_langs, *bad_lang;
275 ok_langs = write_langs (option->flags);
276 bad_lang = write_langs (lang_mask);
278 /* Eventually this should become a hard error IMO. */
279 warning ("command line option \"%s\" is valid for %s but not for %s",
280 text, ok_langs, bad_lang);
286 /* Handle the switch beginning at ARGV for the language indicated by
287 LANG_MASK. Returns the number of switches consumed. */
289 handle_option (char **argv, unsigned int lang_mask)
292 const char *opt, *arg = 0;
295 unsigned int result = 0;
296 const struct cl_option *option;
300 /* Interpret "-" or a non-switch as a file name. */
301 if (opt[0] != '-' || opt[1] == '\0')
303 opt_index = cl_options_count;
305 main_input_filename = opt;
306 result = (*lang_hooks.handle_option) (opt_index, arg, value);
310 /* Drop the "no-" from negative switches. */
311 if ((opt[1] == 'W' || opt[1] == 'f')
312 && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
314 size_t len = strlen (opt) - 3;
316 dup = xmalloc (len + 1);
319 memcpy (dup + 2, opt + 5, len - 2 + 1);
324 opt_index = find_opt (opt + 1, lang_mask | CL_COMMON);
325 if (opt_index == cl_options_count)
328 option = &cl_options[opt_index];
330 /* Reject negative form of switches that don't take negatives as
332 if (!value && (option->flags & CL_REJECT_NEGATIVE))
335 /* We've recognized this switch. */
338 /* Sort out any argument the switch takes. */
339 if (option->flags & CL_JOINED)
341 /* Have arg point to the original switch. This is because
342 some code, such as disable_builtin_function, expects its
343 argument to be persistent until the program exits. */
344 arg = argv[0] + cl_options[opt_index].opt_len + 1;
346 arg += strlen ("no-");
348 if (*arg == '\0' && !(option->flags & CL_MISSING_OK))
350 if (option->flags & CL_SEPARATE)
356 /* Missing argument. */
360 else if (option->flags & CL_SEPARATE)
366 /* Now we've swallowed any potential argument, complain if this
367 is a switch for a different front end. */
368 if (!(option->flags & (lang_mask | CL_COMMON)))
370 complain_wrong_lang (argv[0], option, lang_mask);
374 if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE)))
376 error ("missing argument to \"-%s\"", argv[0]);
380 /* If the switch takes an integer, convert it. */
381 if (arg && (option->flags & CL_UINTEGER))
383 value = integral_argument (arg);
386 error ("argument to \"-%s\" should be a non-negative integer",
392 if (option->flags & lang_mask)
393 if ((*lang_hooks.handle_option) (opt_index, arg, value) == 0)
396 if (result && (option->flags & CL_COMMON))
397 if (common_handle_option (opt_index, arg, value) == 0)
407 /* Decode and handle the vector of command line options. LANG_MASK
408 contains has a single bit set representing the current
411 handle_options (unsigned int argc, char **argv, unsigned int lang_mask)
415 for (i = 1; i < argc; i += n)
417 n = handle_option (argv + i, lang_mask);
422 error ("unrecognized command line option \"%s\"", argv[i]);
427 /* Parse command line options and set default flag values. Do minimal
428 options processing. */
430 decode_options (int argc, char **argv)
434 /* Save in case md file wants to emit args as a comment. */
438 /* Perform language-specific options initialization. */
439 lang_mask = (*lang_hooks.init_options) ();
441 /* Scan to see what optimization level has been specified. That will
442 determine the default value of many flags. */
443 for (i = 1; i < argc; i++)
445 if (!strcmp (argv[i], "-O"))
450 else if (argv[i][0] == '-' && argv[i][1] == 'O')
452 /* Handle -Os, -O2, -O3, -O69, ... */
453 char *p = &argv[i][2];
455 if ((p[0] == 's') && (p[1] == 0))
459 /* Optimizing for size forces optimize to be 2. */
464 const int optimize_val = read_integral_parameter (p, p - 2, -1);
465 if (optimize_val != -1)
467 optimize = optimize_val;
476 flag_merge_constants = 0;
482 flag_thread_jumps = 1;
484 flag_delayed_branch = 1;
486 #ifdef CAN_DEBUG_WITHOUT_FP
487 flag_omit_frame_pointer = 1;
489 flag_guess_branch_prob = 1;
490 flag_cprop_registers = 1;
491 flag_loop_optimize = 1;
492 flag_crossjumping = 1;
493 flag_if_conversion = 1;
494 flag_if_conversion2 = 1;
499 flag_optimize_sibling_calls = 1;
500 flag_cse_follow_jumps = 1;
501 flag_cse_skip_blocks = 1;
503 flag_expensive_optimizations = 1;
504 flag_strength_reduce = 1;
505 flag_rerun_cse_after_loop = 1;
506 flag_rerun_loop_opt = 1;
507 flag_caller_saves = 1;
510 #ifdef INSN_SCHEDULING
511 flag_schedule_insns = 1;
512 flag_schedule_insns_after_reload = 1;
515 flag_strict_aliasing = 1;
516 flag_delete_null_pointer_checks = 1;
517 flag_reorder_blocks = 1;
518 flag_reorder_functions = 1;
523 flag_inline_functions = 1;
524 flag_rename_registers = 1;
525 flag_unswitch_loops = 1;
526 flag_unit_at_a_time = 1;
529 if (optimize < 2 || optimize_size)
536 /* Don't reorder blocks when optimizing for size because extra
537 jump insns may be created; also barrier may create extra padding.
539 More correctly we should have a block reordering mode that tried
540 to minimize the combined size of all the jumps. This would more
541 or less automatically remove extra jumps, but would also try to
542 use more short jumps instead of long jumps. */
543 flag_reorder_blocks = 0;
546 /* Initialize whether `char' is signed. */
547 flag_signed_char = DEFAULT_SIGNED_CHAR;
548 #ifdef DEFAULT_SHORT_ENUMS
549 /* Initialize how much space enums occupy, by default. */
550 flag_short_enums = DEFAULT_SHORT_ENUMS;
553 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
556 set_target_switch ("");
558 /* Unwind tables are always present in an ABI-conformant IA-64
559 object file, so the default should be ON. */
560 #ifdef IA64_UNWIND_INFO
561 flag_unwind_tables = IA64_UNWIND_INFO;
564 #ifdef OPTIMIZATION_OPTIONS
565 /* Allow default optimizations to be specified on a per-machine basis. */
566 OPTIMIZATION_OPTIONS (optimize, optimize_size);
569 handle_options (argc, argv, lang_mask);
573 if (flag_pic && !flag_pie)
576 if (flag_no_inline == 2)
579 flag_really_no_inline = flag_no_inline;
581 /* Set flag_no_inline before the post_options () hook. The C front
582 ends use it to determine tree inlining defaults. FIXME: such
583 code should be lang-independent when all front ends use tree
584 inlining, in which case it, and this condition, should be moved
585 to the top of process_options() instead. */
588 /* Inlining does not work if not optimizing,
589 so force it not to be done. */
593 /* The c_decode_option function and decode_option hook set
594 this to `2' if -Wall is used, so we can avoid giving out
595 lots of errors for people who don't realize what -Wall does. */
596 if (warn_uninitialized == 1)
597 warning ("-Wuninitialized is not supported without -O");
600 if (flag_really_no_inline == 2)
601 flag_really_no_inline = flag_no_inline;
604 /* Handle target- and language-independent options. Return zero to
605 generate an "unknown option" message. */
607 common_handle_option (size_t scode, const char *arg,
608 int value ATTRIBUTE_UNUSED)
610 const struct cl_option *option = &cl_options[scode];
611 enum opt_code code = (enum opt_code) scode;
613 if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE)))
615 error ("missing argument to \"-%s\"", option->opt_text);
626 exit_after_options = true;
633 case OPT__target_help:
634 display_target_options ();
635 exit_after_options = true;
639 print_version (stderr, "");
640 exit_after_options = true;
644 g_switch_value = value;
650 /* Currently handled in a prescan. */
654 /* For backward compatibility, -W is the same as -Wextra. */
658 case OPT_Waggregate_return:
659 warn_aggregate_return = value;
662 case OPT_Wcast_align:
663 warn_cast_align = value;
666 case OPT_Wdeprecated_declarations:
667 warn_deprecated_decl = value;
670 case OPT_Wdisabled_optimization:
671 warn_disabled_optimization = value;
675 warnings_are_errors = value;
686 case OPT_Wlarger_than_:
687 larger_than_size = value;
688 warn_larger_than = value != -1;
691 case OPT_Wmissing_noreturn:
692 warn_missing_noreturn = value;
707 case OPT_Wstrict_aliasing:
708 warn_strict_aliasing = value;
715 case OPT_Wswitch_default:
716 warn_switch_default = value;
719 case OPT_Wswitch_enum:
720 warn_switch_enum = value;
723 case OPT_Wsystem_headers:
724 warn_system_headers = value;
727 case OPT_Wuninitialized:
728 warn_uninitialized = value;
731 case OPT_Wunreachable_code:
732 warn_notreached = value;
739 case OPT_Wunused_function:
740 warn_unused_function = value;
743 case OPT_Wunused_label:
744 warn_unused_label = value;
747 case OPT_Wunused_parameter:
748 warn_unused_parameter = value;
751 case OPT_Wunused_value:
752 warn_unused_value = value;
755 case OPT_Wunused_variable:
756 warn_unused_variable = value;
761 aux_info_file_name = arg;
762 flag_gen_aux_info = 1;
769 case OPT_auxbase_strip:
771 char *tmp = xstrdup (arg);
772 strip_off_ending (tmp, strlen (tmp));
779 decode_d_option (arg);
783 dump_base_name = arg;
787 flag_pic = value + value;
791 flag_pie = value + value;
794 case OPT_falign_functions:
795 case OPT_falign_functions_:
796 align_functions = value;
799 case OPT_falign_jumps:
800 case OPT_falign_jumps_:
804 case OPT_falign_labels:
805 case OPT_falign_labels_:
806 align_labels = value;
809 case OPT_falign_loops:
810 case OPT_falign_loops_:
814 case OPT_fargument_alias:
815 flag_argument_noalias = !value;
818 case OPT_fargument_noalias:
819 flag_argument_noalias = value;
822 case OPT_fargument_noalias_global:
823 flag_argument_noalias = value + value;
826 case OPT_fasynchronous_unwind_tables:
827 flag_asynchronous_unwind_tables = value;
830 case OPT_fbounds_check:
831 flag_bounds_check = value;
834 case OPT_fbranch_count_reg:
835 flag_branch_on_count_reg = value;
838 case OPT_fbranch_probabilities:
839 flag_branch_probabilities = value;
842 case OPT_fbranch_target_load_optimize:
843 flag_branch_target_load_optimize = value;
846 case OPT_fbranch_target_load_optimize2:
847 flag_branch_target_load_optimize2 = value;
850 case OPT_fcall_used_:
851 fix_register (arg, 0, 1);
854 case OPT_fcall_saved_:
855 fix_register (arg, 0, 0);
858 case OPT_fcaller_saves:
859 flag_caller_saves = value;
863 flag_no_common = !value;
866 case OPT_fcprop_registers:
867 flag_cprop_registers = value;
870 case OPT_fcrossjumping:
871 flag_crossjumping = value;
874 case OPT_fcse_follow_jumps:
875 flag_cse_follow_jumps = value;
878 case OPT_fcse_skip_blocks:
879 flag_cse_skip_blocks = value;
882 case OPT_fdata_sections:
883 flag_data_sections = value;
887 flag_defer_pop = value;
890 case OPT_fdelayed_branch:
891 flag_delayed_branch = value;
894 case OPT_fdelete_null_pointer_checks:
895 flag_delete_null_pointer_checks = value;
898 case OPT_fdiagnostics_show_location_:
899 if (!strcmp (arg, "once"))
900 diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
901 else if (!strcmp (arg, "every-line"))
902 diagnostic_prefixing_rule (global_dc)
903 = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
908 case OPT_fdump_unnumbered:
909 flag_dump_unnumbered = value;
912 case OPT_feliminate_dwarf2_dups:
913 flag_eliminate_dwarf2_dups = value;
916 case OPT_feliminate_unused_debug_types:
917 flag_eliminate_unused_debug_types = value;
920 case OPT_feliminate_unused_debug_symbols:
921 flag_debug_only_used_symbols = value;
924 case OPT_fexceptions:
925 flag_exceptions = value;
928 case OPT_fexpensive_optimizations:
929 flag_expensive_optimizations = value;
933 set_fast_math_flags (value);
936 case OPT_ffinite_math_only:
937 flag_finite_math_only = value;
941 fix_register (arg, 1, 1);
944 case OPT_ffunction_cse:
945 flag_no_function_cse = !value;
948 case OPT_ffloat_store:
949 flag_float_store = value;
952 case OPT_fforce_addr:
953 flag_force_addr = value;
957 flag_force_mem = value;
960 case OPT_ffunction_sections:
961 flag_function_sections = value;
969 flag_gcse_lm = value;
973 flag_gcse_sm = value;
976 case OPT_fgnu_linker:
977 flag_gnu_linker = value;
980 case OPT_fguess_branch_probability:
981 flag_guess_branch_prob = value;
985 flag_no_ident = !value;
988 case OPT_fif_conversion:
989 flag_if_conversion = value;
992 case OPT_fif_conversion2:
993 flag_if_conversion2 = value;
996 case OPT_finhibit_size_directive:
997 flag_inhibit_size_directive = value;
1001 flag_no_inline = !value;
1004 case OPT_finline_functions:
1005 flag_inline_functions = value;
1008 case OPT_finline_limit_:
1009 case OPT_finline_limit_eq:
1010 set_param_value ("max-inline-insns", value);
1011 set_param_value ("max-inline-insns-single", value / 2);
1012 set_param_value ("max-inline-insns-auto", value / 2);
1013 set_param_value ("max-inline-insns-rtl", value);
1014 if (value / 4 < MIN_INLINE_INSNS)
1017 set_param_value ("min-inline-insns", value / 4);
1019 set_param_value ("min-inline-insns", 10);
1023 case OPT_finstrument_functions:
1024 flag_instrument_function_entry_exit = value;
1027 case OPT_fkeep_inline_functions:
1028 flag_keep_inline_functions =value;
1031 case OPT_fkeep_static_consts:
1032 flag_keep_static_consts = value;
1035 case OPT_fleading_underscore:
1036 flag_leading_underscore = value;
1039 case OPT_floop_optimize:
1040 flag_loop_optimize = value;
1043 case OPT_fmath_errno:
1044 flag_errno_math = value;
1047 case OPT_fmem_report:
1051 case OPT_fmerge_all_constants:
1052 flag_merge_constants = value + value;
1055 case OPT_fmerge_constants:
1056 flag_merge_constants = value;
1059 case OPT_fmessage_length_:
1060 output_set_maximum_length (&global_dc->buffer, value);
1063 case OPT_fmove_all_movables:
1064 flag_move_all_movables = value;
1068 flag_new_regalloc = value;
1071 case OPT_fnon_call_exceptions:
1072 flag_non_call_exceptions = value;
1075 case OPT_fold_unroll_all_loops:
1076 flag_old_unroll_all_loops = value;
1079 case OPT_fold_unroll_loops:
1080 flag_old_unroll_loops = value;
1083 case OPT_fomit_frame_pointer:
1084 flag_omit_frame_pointer = value;
1087 case OPT_foptimize_register_move:
1088 flag_regmove = value;
1091 case OPT_foptimize_sibling_calls:
1092 flag_optimize_sibling_calls = value;
1095 case OPT_fpack_struct:
1096 flag_pack_struct = value;
1099 case OPT_fpeel_loops:
1100 flag_peel_loops = value;
1103 case OPT_fpcc_struct_return:
1104 flag_pcc_struct_return = value;
1108 flag_no_peephole = !value;
1111 case OPT_fpeephole2:
1112 flag_peephole2 = value;
1123 case OPT_fprefetch_loop_arrays:
1124 flag_prefetch_loop_arrays = value;
1128 profile_flag = value;
1131 case OPT_fprofile_arcs:
1132 profile_arc_flag = value;
1135 case OPT_frandom_seed:
1136 /* The real switch is -fno-random-seed. */
1139 flag_random_seed = NULL;
1142 case OPT_frandom_seed_:
1143 flag_random_seed = arg;
1146 case OPT_freduce_all_givs:
1147 flag_reduce_all_givs = value;
1150 case OPT_freg_struct_return:
1151 flag_pcc_struct_return = !value;
1155 flag_regmove = value;
1158 case OPT_frename_registers:
1159 flag_rename_registers = value;
1162 case OPT_freorder_blocks:
1163 flag_reorder_blocks = value;
1166 case OPT_freorder_functions:
1167 flag_reorder_functions = value;
1170 case OPT_frerun_cse_after_loop:
1171 flag_rerun_cse_after_loop = value;
1174 case OPT_frerun_loop_opt:
1175 flag_rerun_loop_opt = value;
1178 case OPT_fsched_interblock:
1179 flag_schedule_interblock= value;
1182 case OPT_fsched_spec:
1183 flag_schedule_speculative = value;
1186 case OPT_fsched_spec_load:
1187 flag_schedule_speculative_load = value;
1190 case OPT_fsched_spec_load_dangerous:
1191 flag_schedule_speculative_load_dangerous = value;
1194 case OPT_fsched_verbose_:
1195 #ifdef INSN_SCHEDULING
1196 fix_sched_param ("verbose", arg);
1202 case OPT_fsched2_use_superblocks:
1203 flag_sched2_use_superblocks = value;
1206 case OPT_fsched2_use_traces:
1207 flag_sched2_use_traces = value;
1210 case OPT_fschedule_insns:
1211 flag_schedule_insns = value;
1214 case OPT_fschedule_insns2:
1215 flag_schedule_insns_after_reload = value;
1218 case OPT_fshared_data:
1219 flag_shared_data = value;
1222 case OPT_fsignaling_nans:
1223 flag_signaling_nans = value;
1226 case OPT_fsingle_precision_constant:
1227 flag_single_precision_constant = value;
1235 flag_ssa_ccp = value;
1239 flag_ssa_dce = value;
1242 case OPT_fstack_check:
1243 flag_stack_check = value;
1246 case OPT_fstack_limit:
1247 /* The real switch is -fno-stack-limit. */
1250 stack_limit_rtx = NULL_RTX;
1253 case OPT_fstack_limit_register_:
1255 int reg = decode_reg_name (arg);
1257 error ("unrecognized register name \"%s\"", arg);
1259 stack_limit_rtx = gen_rtx_REG (Pmode, reg);
1263 case OPT_fstack_limit_symbol_:
1264 stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (arg));
1267 case OPT_fstrength_reduce:
1268 flag_strength_reduce = value;
1271 case OPT_fstrict_aliasing:
1272 flag_strict_aliasing = value;
1275 case OPT_fsyntax_only:
1276 flag_syntax_only = value;
1279 case OPT_ftest_coverage:
1280 flag_test_coverage = value;
1283 case OPT_fthread_jumps:
1284 flag_thread_jumps = value;
1287 case OPT_ftime_report:
1288 time_report = value;
1291 case OPT_ftls_model_:
1292 if (!strcmp (arg, "global-dynamic"))
1293 flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
1294 else if (!strcmp (arg, "local-dynamic"))
1295 flag_tls_default = TLS_MODEL_LOCAL_DYNAMIC;
1296 else if (!strcmp (arg, "initial-exec"))
1297 flag_tls_default = TLS_MODEL_INITIAL_EXEC;
1298 else if (!strcmp (arg, "local-exec"))
1299 flag_tls_default = TLS_MODEL_LOCAL_EXEC;
1301 warning ("unknown tls-model \"%s\"", arg);
1305 flag_tracer = value;
1308 case OPT_ftrapping_math:
1309 flag_trapping_math = value;
1316 case OPT_funit_at_a_time:
1317 flag_unit_at_a_time = value;
1320 case OPT_funroll_all_loops:
1321 flag_unroll_all_loops = value;
1324 case OPT_funroll_loops:
1325 flag_unroll_loops = value;
1328 case OPT_funsafe_math_optimizations:
1329 flag_unsafe_math_optimizations = value;
1332 case OPT_funswitch_loops:
1333 flag_unswitch_loops = value;
1336 case OPT_funwind_tables:
1337 flag_unwind_tables = value;
1340 case OPT_fverbose_asm:
1341 flag_verbose_asm = value;
1348 case OPT_fwritable_strings:
1349 flag_writable_strings = value;
1352 case OPT_fzero_initialized_in_bss:
1353 flag_zero_initialized_in_bss = value;
1357 decode_g_option (arg);
1361 set_target_switch (arg);
1365 asm_file_name = arg;
1376 case OPT_pedantic_errors:
1377 flag_pedantic_errors = pedantic = 1;
1389 inhibit_warnings = true;
1396 /* Handle --param NAME=VALUE. */
1398 handle_param (const char *carg)
1403 arg = xstrdup (carg);
1404 equal = strchr (arg, '=');
1406 error ("%s: --param arguments should be of the form NAME=VALUE", arg);
1409 value = integral_argument (equal + 1);
1411 error ("invalid --param value `%s'", equal + 1);
1415 set_param_value (arg, value);
1422 /* Handle -W and -Wextra. */
1424 set_Wextra (int setting)
1426 extra_warnings = setting;
1427 warn_unused_value = setting;
1428 warn_unused_parameter = (setting && maybe_warn_unused_parameter);
1430 /* We save the value of warn_uninitialized, since if they put
1431 -Wuninitialized on the command line, we need to generate a
1432 warning about not using it without also specifying -O. */
1434 warn_uninitialized = 0;
1435 else if (warn_uninitialized != 1)
1436 warn_uninitialized = 2;
1439 /* Initialize unused warning flags. */
1441 set_Wunused (int setting)
1443 warn_unused_function = setting;
1444 warn_unused_label = setting;
1445 /* Unused function parameter warnings are reported when either
1446 ``-Wextra -Wunused'' or ``-Wunused-parameter'' is specified.
1447 Thus, if -Wextra has already been seen, set warn_unused_parameter;
1448 otherwise set maybe_warn_extra_parameter, which will be picked up
1450 maybe_warn_unused_parameter = setting;
1451 warn_unused_parameter = (setting && extra_warnings);
1452 warn_unused_variable = setting;
1453 warn_unused_value = setting;
1456 /* The following routines are useful in setting all the flags that
1457 -ffast-math and -fno-fast-math imply. */
1459 set_fast_math_flags (int set)
1461 flag_trapping_math = !set;
1462 flag_unsafe_math_optimizations = set;
1463 flag_finite_math_only = set;
1464 flag_errno_math = !set;
1466 flag_signaling_nans = 0;
1469 /* Return true iff flags are set as if -ffast-math. */
1471 fast_math_flags_set_p (void)
1473 return (!flag_trapping_math
1474 && flag_unsafe_math_optimizations
1475 && flag_finite_math_only
1476 && !flag_errno_math);