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 (const 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, const char **, unsigned int);
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 (const 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
, const 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 (unsigned int argc
, const char **argv
)
432 unsigned int i
, lang_mask
;
434 /* Perform language-specific options initialization. */
435 lang_mask
= (*lang_hooks
.init_options
) (argc
, argv
);
437 /* Scan to see what optimization level has been specified. That will
438 determine the default value of many flags. */
439 for (i
= 1; i
< argc
; i
++)
441 if (!strcmp (argv
[i
], "-O"))
446 else if (argv
[i
][0] == '-' && argv
[i
][1] == 'O')
448 /* Handle -Os, -O2, -O3, -O69, ... */
449 const char *p
= &argv
[i
][2];
451 if ((p
[0] == 's') && (p
[1] == 0))
455 /* Optimizing for size forces optimize to be 2. */
460 const int optimize_val
= read_integral_parameter (p
, p
- 2, -1);
461 if (optimize_val
!= -1)
463 optimize
= optimize_val
;
472 flag_merge_constants
= 0;
478 flag_thread_jumps
= 1;
480 flag_delayed_branch
= 1;
482 #ifdef CAN_DEBUG_WITHOUT_FP
483 flag_omit_frame_pointer
= 1;
485 flag_guess_branch_prob
= 1;
486 flag_cprop_registers
= 1;
487 flag_loop_optimize
= 1;
488 flag_crossjumping
= 1;
489 flag_if_conversion
= 1;
490 flag_if_conversion2
= 1;
495 flag_optimize_sibling_calls
= 1;
496 flag_cse_follow_jumps
= 1;
497 flag_cse_skip_blocks
= 1;
499 flag_expensive_optimizations
= 1;
500 flag_strength_reduce
= 1;
501 flag_rerun_cse_after_loop
= 1;
502 flag_rerun_loop_opt
= 1;
503 flag_caller_saves
= 1;
506 #ifdef INSN_SCHEDULING
507 flag_schedule_insns
= 1;
508 flag_schedule_insns_after_reload
= 1;
511 flag_strict_aliasing
= 1;
512 flag_delete_null_pointer_checks
= 1;
513 flag_reorder_blocks
= 1;
514 flag_reorder_functions
= 1;
519 flag_inline_functions
= 1;
520 flag_rename_registers
= 1;
521 flag_unswitch_loops
= 1;
522 flag_unit_at_a_time
= 1;
525 if (optimize
< 2 || optimize_size
)
532 /* Don't reorder blocks when optimizing for size because extra
533 jump insns may be created; also barrier may create extra padding.
535 More correctly we should have a block reordering mode that tried
536 to minimize the combined size of all the jumps. This would more
537 or less automatically remove extra jumps, but would also try to
538 use more short jumps instead of long jumps. */
539 flag_reorder_blocks
= 0;
542 /* Initialize whether `char' is signed. */
543 flag_signed_char
= DEFAULT_SIGNED_CHAR
;
544 #ifdef DEFAULT_SHORT_ENUMS
545 /* Initialize how much space enums occupy, by default. */
546 flag_short_enums
= DEFAULT_SHORT_ENUMS
;
549 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
552 set_target_switch ("");
554 /* Unwind tables are always present in an ABI-conformant IA-64
555 object file, so the default should be ON. */
556 #ifdef IA64_UNWIND_INFO
557 flag_unwind_tables
= IA64_UNWIND_INFO
;
560 #ifdef OPTIMIZATION_OPTIONS
561 /* Allow default optimizations to be specified on a per-machine basis. */
562 OPTIMIZATION_OPTIONS (optimize
, optimize_size
);
565 handle_options (argc
, argv
, lang_mask
);
569 if (flag_pic
&& !flag_pie
)
572 if (flag_no_inline
== 2)
575 flag_really_no_inline
= flag_no_inline
;
577 /* Set flag_no_inline before the post_options () hook. The C front
578 ends use it to determine tree inlining defaults. FIXME: such
579 code should be lang-independent when all front ends use tree
580 inlining, in which case it, and this condition, should be moved
581 to the top of process_options() instead. */
584 /* Inlining does not work if not optimizing,
585 so force it not to be done. */
589 /* The c_decode_option function and decode_option hook set
590 this to `2' if -Wall is used, so we can avoid giving out
591 lots of errors for people who don't realize what -Wall does. */
592 if (warn_uninitialized
== 1)
593 warning ("-Wuninitialized is not supported without -O");
596 if (flag_really_no_inline
== 2)
597 flag_really_no_inline
= flag_no_inline
;
600 /* Handle target- and language-independent options. Return zero to
601 generate an "unknown option" message. */
603 common_handle_option (size_t scode
, const char *arg
,
604 int value ATTRIBUTE_UNUSED
)
606 const struct cl_option
*option
= &cl_options
[scode
];
607 enum opt_code code
= (enum opt_code
) scode
;
609 if (arg
== NULL
&& (option
->flags
& (CL_JOINED
| CL_SEPARATE
)))
611 error ("missing argument to \"-%s\"", option
->opt_text
);
622 exit_after_options
= true;
629 case OPT__target_help
:
630 display_target_options ();
631 exit_after_options
= true;
635 print_version (stderr
, "");
636 exit_after_options
= true;
640 g_switch_value
= value
;
646 /* Currently handled in a prescan. */
650 /* For backward compatibility, -W is the same as -Wextra. */
654 case OPT_Waggregate_return
:
655 warn_aggregate_return
= value
;
658 case OPT_Wcast_align
:
659 warn_cast_align
= value
;
662 case OPT_Wdeprecated_declarations
:
663 warn_deprecated_decl
= value
;
666 case OPT_Wdisabled_optimization
:
667 warn_disabled_optimization
= value
;
671 warnings_are_errors
= value
;
682 case OPT_Wlarger_than_
:
683 larger_than_size
= value
;
684 warn_larger_than
= value
!= -1;
687 case OPT_Wmissing_noreturn
:
688 warn_missing_noreturn
= value
;
703 case OPT_Wstrict_aliasing
:
704 warn_strict_aliasing
= value
;
711 case OPT_Wswitch_default
:
712 warn_switch_default
= value
;
715 case OPT_Wswitch_enum
:
716 warn_switch_enum
= value
;
719 case OPT_Wsystem_headers
:
720 warn_system_headers
= value
;
723 case OPT_Wuninitialized
:
724 warn_uninitialized
= value
;
727 case OPT_Wunreachable_code
:
728 warn_notreached
= value
;
735 case OPT_Wunused_function
:
736 warn_unused_function
= value
;
739 case OPT_Wunused_label
:
740 warn_unused_label
= value
;
743 case OPT_Wunused_parameter
:
744 warn_unused_parameter
= value
;
747 case OPT_Wunused_value
:
748 warn_unused_value
= value
;
751 case OPT_Wunused_variable
:
752 warn_unused_variable
= value
;
757 aux_info_file_name
= arg
;
758 flag_gen_aux_info
= 1;
765 case OPT_auxbase_strip
:
767 char *tmp
= xstrdup (arg
);
768 strip_off_ending (tmp
, strlen (tmp
));
775 decode_d_option (arg
);
779 dump_base_name
= arg
;
783 flag_pic
= value
+ value
;
787 flag_pie
= value
+ value
;
790 case OPT_falign_functions
:
791 case OPT_falign_functions_
:
792 align_functions
= !value
;
795 case OPT_falign_jumps
:
796 case OPT_falign_jumps_
:
797 align_jumps
= !value
;
800 case OPT_falign_labels
:
801 case OPT_falign_labels_
:
802 align_labels
= !value
;
805 case OPT_falign_loops
:
806 case OPT_falign_loops_
:
807 align_loops
= !value
;
810 case OPT_fargument_alias
:
811 flag_argument_noalias
= !value
;
814 case OPT_fargument_noalias
:
815 flag_argument_noalias
= value
;
818 case OPT_fargument_noalias_global
:
819 flag_argument_noalias
= value
+ value
;
822 case OPT_fasynchronous_unwind_tables
:
823 flag_asynchronous_unwind_tables
= value
;
826 case OPT_fbounds_check
:
827 flag_bounds_check
= value
;
830 case OPT_fbranch_count_reg
:
831 flag_branch_on_count_reg
= value
;
834 case OPT_fbranch_probabilities
:
835 flag_branch_probabilities
= value
;
838 case OPT_fbranch_target_load_optimize
:
839 flag_branch_target_load_optimize
= value
;
842 case OPT_fbranch_target_load_optimize2
:
843 flag_branch_target_load_optimize2
= value
;
846 case OPT_fcall_used_
:
847 fix_register (arg
, 0, 1);
850 case OPT_fcall_saved_
:
851 fix_register (arg
, 0, 0);
854 case OPT_fcaller_saves
:
855 flag_caller_saves
= value
;
859 flag_no_common
= !value
;
862 case OPT_fcprop_registers
:
863 flag_cprop_registers
= value
;
866 case OPT_fcrossjumping
:
867 flag_crossjumping
= value
;
870 case OPT_fcse_follow_jumps
:
871 flag_cse_follow_jumps
= value
;
874 case OPT_fcse_skip_blocks
:
875 flag_cse_skip_blocks
= value
;
878 case OPT_fdata_sections
:
879 flag_data_sections
= value
;
883 flag_defer_pop
= value
;
886 case OPT_fdelayed_branch
:
887 flag_delayed_branch
= value
;
890 case OPT_fdelete_null_pointer_checks
:
891 flag_delete_null_pointer_checks
= value
;
894 case OPT_fdiagnostics_show_location_
:
895 if (!strcmp (arg
, "once"))
896 diagnostic_prefixing_rule (global_dc
) = DIAGNOSTICS_SHOW_PREFIX_ONCE
;
897 else if (!strcmp (arg
, "every-line"))
898 diagnostic_prefixing_rule (global_dc
)
899 = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE
;
904 case OPT_fdump_unnumbered
:
905 flag_dump_unnumbered
= value
;
908 case OPT_feliminate_dwarf2_dups
:
909 flag_eliminate_dwarf2_dups
= value
;
912 case OPT_feliminate_unused_debug_types
:
913 flag_eliminate_unused_debug_types
= value
;
916 case OPT_feliminate_unused_debug_symbols
:
917 flag_debug_only_used_symbols
= value
;
920 case OPT_fexceptions
:
921 flag_exceptions
= value
;
924 case OPT_fexpensive_optimizations
:
925 flag_expensive_optimizations
= value
;
929 set_fast_math_flags (value
);
932 case OPT_ffinite_math_only
:
933 flag_finite_math_only
= value
;
937 fix_register (arg
, 1, 1);
940 case OPT_ffunction_cse
:
941 flag_no_function_cse
= !value
;
944 case OPT_ffloat_store
:
945 flag_float_store
= value
;
948 case OPT_fforce_addr
:
949 flag_force_addr
= value
;
953 flag_force_mem
= value
;
956 case OPT_ffunction_sections
:
957 flag_function_sections
= value
;
965 flag_gcse_lm
= value
;
969 flag_gcse_sm
= value
;
972 case OPT_fgnu_linker
:
973 flag_gnu_linker
= value
;
976 case OPT_fguess_branch_probability
:
977 flag_guess_branch_prob
= value
;
981 flag_no_ident
= !value
;
984 case OPT_fif_conversion
:
985 flag_if_conversion
= value
;
988 case OPT_fif_conversion2
:
989 flag_if_conversion2
= value
;
992 case OPT_finhibit_size_directive
:
993 flag_inhibit_size_directive
= value
;
997 flag_no_inline
= !value
;
1000 case OPT_finline_functions
:
1001 flag_inline_functions
= value
;
1004 case OPT_finline_limit_
:
1005 case OPT_finline_limit_eq
:
1006 set_param_value ("max-inline-insns", value
);
1007 set_param_value ("max-inline-insns-single", value
/ 2);
1008 set_param_value ("max-inline-insns-auto", value
/ 2);
1009 set_param_value ("max-inline-insns-rtl", value
);
1010 if (value
/ 4 < MIN_INLINE_INSNS
)
1013 set_param_value ("min-inline-insns", value
/ 4);
1015 set_param_value ("min-inline-insns", 10);
1019 case OPT_finstrument_functions
:
1020 flag_instrument_function_entry_exit
= value
;
1023 case OPT_fkeep_inline_functions
:
1024 flag_keep_inline_functions
=value
;
1027 case OPT_fkeep_static_consts
:
1028 flag_keep_static_consts
= value
;
1031 case OPT_fleading_underscore
:
1032 flag_leading_underscore
= value
;
1035 case OPT_floop_optimize
:
1036 flag_loop_optimize
= value
;
1039 case OPT_fmath_errno
:
1040 flag_errno_math
= value
;
1043 case OPT_fmem_report
:
1047 case OPT_fmerge_all_constants
:
1048 flag_merge_constants
= value
+ value
;
1051 case OPT_fmerge_constants
:
1052 flag_merge_constants
= value
;
1055 case OPT_fmessage_length_
:
1056 output_set_maximum_length (&global_dc
->buffer
, value
);
1059 case OPT_fmove_all_movables
:
1060 flag_move_all_movables
= value
;
1064 flag_new_regalloc
= value
;
1067 case OPT_fnon_call_exceptions
:
1068 flag_non_call_exceptions
= value
;
1071 case OPT_fold_unroll_all_loops
:
1072 flag_old_unroll_all_loops
= value
;
1075 case OPT_fold_unroll_loops
:
1076 flag_old_unroll_loops
= value
;
1079 case OPT_fomit_frame_pointer
:
1080 flag_omit_frame_pointer
= value
;
1083 case OPT_foptimize_register_move
:
1084 flag_regmove
= value
;
1087 case OPT_foptimize_sibling_calls
:
1088 flag_optimize_sibling_calls
= value
;
1091 case OPT_fpack_struct
:
1092 flag_pack_struct
= value
;
1095 case OPT_fpeel_loops
:
1096 flag_peel_loops
= value
;
1099 case OPT_fpcc_struct_return
:
1100 flag_pcc_struct_return
= value
;
1104 flag_no_peephole
= !value
;
1107 case OPT_fpeephole2
:
1108 flag_peephole2
= value
;
1119 case OPT_fprefetch_loop_arrays
:
1120 flag_prefetch_loop_arrays
= value
;
1124 profile_flag
= value
;
1127 case OPT_fprofile_arcs
:
1128 profile_arc_flag
= value
;
1131 case OPT_frandom_seed
:
1132 /* The real switch is -fno-random-seed. */
1135 flag_random_seed
= NULL
;
1138 case OPT_frandom_seed_
:
1139 flag_random_seed
= arg
;
1142 case OPT_freduce_all_givs
:
1143 flag_reduce_all_givs
= value
;
1146 case OPT_freg_struct_return
:
1147 flag_pcc_struct_return
= !value
;
1151 flag_regmove
= value
;
1154 case OPT_frename_registers
:
1155 flag_rename_registers
= value
;
1158 case OPT_freorder_blocks
:
1159 flag_reorder_blocks
= value
;
1162 case OPT_freorder_functions
:
1163 flag_reorder_functions
= value
;
1166 case OPT_frerun_cse_after_loop
:
1167 flag_rerun_cse_after_loop
= value
;
1170 case OPT_frerun_loop_opt
:
1171 flag_rerun_loop_opt
= value
;
1174 case OPT_fsched_interblock
:
1175 flag_schedule_interblock
= value
;
1178 case OPT_fsched_spec
:
1179 flag_schedule_speculative
= value
;
1182 case OPT_fsched_spec_load
:
1183 flag_schedule_speculative_load
= value
;
1186 case OPT_fsched_spec_load_dangerous
:
1187 flag_schedule_speculative_load_dangerous
= value
;
1190 case OPT_fsched_verbose_
:
1191 #ifdef INSN_SCHEDULING
1192 fix_sched_param ("verbose", arg
);
1198 case OPT_fsched2_use_superblocks
:
1199 flag_sched2_use_superblocks
= value
;
1202 case OPT_fsched2_use_traces
:
1203 flag_sched2_use_traces
= value
;
1206 case OPT_fschedule_insns
:
1207 flag_schedule_insns
= value
;
1210 case OPT_fschedule_insns2
:
1211 flag_schedule_insns_after_reload
= value
;
1214 case OPT_fshared_data
:
1215 flag_shared_data
= value
;
1218 case OPT_fsignaling_nans
:
1219 flag_signaling_nans
= value
;
1222 case OPT_fsingle_precision_constant
:
1223 flag_single_precision_constant
= value
;
1231 flag_ssa_ccp
= value
;
1235 flag_ssa_dce
= value
;
1238 case OPT_fstack_check
:
1239 flag_stack_check
= value
;
1242 case OPT_fstack_limit
:
1243 /* The real switch is -fno-stack-limit. */
1246 stack_limit_rtx
= NULL_RTX
;
1249 case OPT_fstack_limit_register_
:
1251 int reg
= decode_reg_name (arg
);
1253 error ("unrecognized register name \"%s\"", arg
);
1255 stack_limit_rtx
= gen_rtx_REG (Pmode
, reg
);
1259 case OPT_fstack_limit_symbol_
:
1260 stack_limit_rtx
= gen_rtx_SYMBOL_REF (Pmode
, ggc_strdup (arg
));
1263 case OPT_fstrength_reduce
:
1264 flag_strength_reduce
= value
;
1267 case OPT_fstrict_aliasing
:
1268 flag_strict_aliasing
= value
;
1271 case OPT_fsyntax_only
:
1272 flag_syntax_only
= value
;
1275 case OPT_ftest_coverage
:
1276 flag_test_coverage
= value
;
1279 case OPT_fthread_jumps
:
1280 flag_thread_jumps
= value
;
1283 case OPT_ftime_report
:
1284 time_report
= value
;
1287 case OPT_ftls_model_
:
1288 if (!strcmp (arg
, "global-dynamic"))
1289 flag_tls_default
= TLS_MODEL_GLOBAL_DYNAMIC
;
1290 else if (!strcmp (arg
, "local-dynamic"))
1291 flag_tls_default
= TLS_MODEL_LOCAL_DYNAMIC
;
1292 else if (!strcmp (arg
, "initial-exec"))
1293 flag_tls_default
= TLS_MODEL_INITIAL_EXEC
;
1294 else if (!strcmp (arg
, "local-exec"))
1295 flag_tls_default
= TLS_MODEL_LOCAL_EXEC
;
1297 warning ("unknown tls-model \"%s\"", arg
);
1301 flag_tracer
= value
;
1304 case OPT_ftrapping_math
:
1305 flag_trapping_math
= value
;
1312 case OPT_funit_at_a_time
:
1313 flag_unit_at_a_time
= value
;
1316 case OPT_funroll_all_loops
:
1317 flag_unroll_all_loops
= value
;
1320 case OPT_funroll_loops
:
1321 flag_unroll_loops
= value
;
1324 case OPT_funsafe_math_optimizations
:
1325 flag_unsafe_math_optimizations
= value
;
1328 case OPT_funswitch_loops
:
1329 flag_unswitch_loops
= value
;
1332 case OPT_funwind_tables
:
1333 flag_unwind_tables
= value
;
1336 case OPT_fverbose_asm
:
1337 flag_verbose_asm
= value
;
1344 case OPT_fwritable_strings
:
1345 flag_writable_strings
= value
;
1348 case OPT_fzero_initialized_in_bss
:
1349 flag_zero_initialized_in_bss
= value
;
1353 decode_g_option (arg
);
1357 set_target_switch (arg
);
1361 asm_file_name
= arg
;
1372 case OPT_pedantic_errors
:
1373 flag_pedantic_errors
= pedantic
= 1;
1385 inhibit_warnings
= true;
1392 /* Handle --param NAME=VALUE. */
1394 handle_param (const char *carg
)
1399 arg
= xstrdup (carg
);
1400 equal
= strchr (arg
, '=');
1402 error ("%s: --param arguments should be of the form NAME=VALUE", arg
);
1405 value
= integral_argument (equal
+ 1);
1407 error ("invalid --param value `%s'", equal
+ 1);
1411 set_param_value (arg
, value
);
1418 /* Handle -W and -Wextra. */
1420 set_Wextra (int setting
)
1422 extra_warnings
= setting
;
1423 warn_unused_value
= setting
;
1424 warn_unused_parameter
= (setting
&& maybe_warn_unused_parameter
);
1426 /* We save the value of warn_uninitialized, since if they put
1427 -Wuninitialized on the command line, we need to generate a
1428 warning about not using it without also specifying -O. */
1430 warn_uninitialized
= 0;
1431 else if (warn_uninitialized
!= 1)
1432 warn_uninitialized
= 2;
1435 /* Initialize unused warning flags. */
1437 set_Wunused (int setting
)
1439 warn_unused_function
= setting
;
1440 warn_unused_label
= setting
;
1441 /* Unused function parameter warnings are reported when either
1442 ``-Wextra -Wunused'' or ``-Wunused-parameter'' is specified.
1443 Thus, if -Wextra has already been seen, set warn_unused_parameter;
1444 otherwise set maybe_warn_extra_parameter, which will be picked up
1446 maybe_warn_unused_parameter
= setting
;
1447 warn_unused_parameter
= (setting
&& extra_warnings
);
1448 warn_unused_variable
= setting
;
1449 warn_unused_value
= setting
;
1452 /* The following routines are useful in setting all the flags that
1453 -ffast-math and -fno-fast-math imply. */
1455 set_fast_math_flags (int set
)
1457 flag_trapping_math
= !set
;
1458 flag_unsafe_math_optimizations
= set
;
1459 flag_finite_math_only
= set
;
1460 flag_errno_math
= !set
;
1462 flag_signaling_nans
= 0;
1465 /* Return true iff flags are set as if -ffast-math. */
1467 fast_math_flags_set_p (void)
1469 return (!flag_trapping_math
1470 && flag_unsafe_math_optimizations
1471 && flag_finite_math_only
1472 && !flag_errno_math
);