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 static size_t find_opt (const char *, int);
132 static int common_handle_option (size_t scode
, const char *arg
, int value
);
133 static void handle_param (const char *);
134 static void set_Wextra (int);
135 static unsigned int handle_option (const char **argv
, unsigned int lang_mask
);
136 static char *write_langs (unsigned int lang_mask
);
137 static void complain_wrong_lang (const char *, const struct cl_option
*,
138 unsigned int lang_mask
);
139 static void handle_options (unsigned int, const char **, unsigned int);
140 static void wrap_help (const char *help
, const char *item
, int item_width
);
141 static void print_help (void);
143 /* Perform a binary search to find which option the command-line INPUT
144 matches. Returns its index in the option array, and N_OPTS
145 (cl_options_count) on failure.
147 This routine is quite subtle. A normal binary search is not good
148 enough because some options can be suffixed with an argument, and
149 multiple sub-matches can occur, e.g. input of "-pedantic" matching
150 the initial substring of "-pedantic-errors".
152 A more complicated example is -gstabs. It should match "-g" with
153 an argument of "stabs". Suppose, however, that the number and list
154 of switches are such that the binary search tests "-gen-decls"
155 before having tested "-g". This doesn't match, and as "-gen-decls"
156 is less than "-gstabs", it will become the lower bound of the
157 binary search range, and "-g" will never be seen. To resolve this
158 issue, opts.sh makes "-gen-decls" point, via the back_chain member,
159 to "-g" so that failed searches that end between "-gen-decls" and
160 the lexicographically subsequent switch know to go back and see if
161 "-g" causes a match (which it does in this example).
163 This search is done in such a way that the longest match for the
164 front end in question wins. If there is no match for the current
165 front end, the longest match for a different front end is returned
166 (or N_OPTS if none) and the caller emits an error message. */
168 find_opt (const char *input
, int lang_mask
)
170 size_t mn
, mx
, md
, opt_len
;
171 size_t match_wrong_lang
;
175 mx
= cl_options_count
;
177 /* Find mn such this lexicographical inequality holds:
178 cl_options[mn] <= input < cl_options[mn + 1]. */
182 opt_len
= cl_options
[md
].opt_len
;
183 comp
= strncmp (input
, cl_options
[md
].opt_text
+ 1, opt_len
);
191 /* This is the switch that is the best match but for a different
192 front end, or cl_options_count if there is no match at all. */
193 match_wrong_lang
= cl_options_count
;
195 /* Backtrace the chain of possible matches, returning the longest
196 one, if any, that fits best. With current GCC switches, this
197 loop executes at most twice. */
200 const struct cl_option
*opt
= &cl_options
[mn
];
202 /* Is this switch a prefix of the input? */
203 if (!strncmp (input
, opt
->opt_text
+ 1, opt
->opt_len
))
205 /* If language is OK, and the match is exact or the switch
206 takes a joined argument, return it. */
207 if ((opt
->flags
& lang_mask
)
208 && (input
[opt
->opt_len
] == '\0' || (opt
->flags
& CL_JOINED
)))
211 /* If we haven't remembered a prior match, remember this
212 one. Any prior match is necessarily better. */
213 if (match_wrong_lang
== cl_options_count
)
214 match_wrong_lang
= mn
;
217 /* Try the next possibility. This is cl_options_count if there
219 mn
= opt
->back_chain
;
221 while (mn
!= cl_options_count
);
223 /* Return the best wrong match, or cl_options_count if none. */
224 return match_wrong_lang
;
227 /* If ARG is a non-negative integer made up solely of digits, return its
228 value, otherwise return -1. */
230 integral_argument (const char *arg
)
234 while (*p
&& ISDIGIT (*p
))
243 /* Return a malloced slash-separated list of languages in MASK. */
245 write_langs (unsigned int mask
)
247 unsigned int n
= 0, len
= 0;
248 const char *lang_name
;
251 for (n
= 0; (lang_name
= lang_names
[n
]) != 0; n
++)
252 if (mask
& (1U << n
))
253 len
+= strlen (lang_name
) + 1;
255 result
= xmalloc (len
);
257 for (n
= 0; (lang_name
= lang_names
[n
]) != 0; n
++)
258 if (mask
& (1U << n
))
262 strcpy (result
+ len
, lang_name
);
263 len
+= strlen (lang_name
);
271 /* Complain that switch OPT_INDEX does not apply to this front end. */
273 complain_wrong_lang (const char *text
, const struct cl_option
*option
,
274 unsigned int lang_mask
)
276 char *ok_langs
, *bad_lang
;
278 ok_langs
= write_langs (option
->flags
);
279 bad_lang
= write_langs (lang_mask
);
281 /* Eventually this should become a hard error IMO. */
282 warning ("command line option \"%s\" is valid for %s but not for %s",
283 text
, ok_langs
, bad_lang
);
289 /* Handle the switch beginning at ARGV for the language indicated by
290 LANG_MASK. Returns the number of switches consumed. */
292 handle_option (const char **argv
, unsigned int lang_mask
)
295 const char *opt
, *arg
= 0;
298 unsigned int result
= 0;
299 const struct cl_option
*option
;
303 /* Drop the "no-" from negative switches. */
304 if ((opt
[1] == 'W' || opt
[1] == 'f')
305 && opt
[2] == 'n' && opt
[3] == 'o' && opt
[4] == '-')
307 size_t len
= strlen (opt
) - 3;
309 dup
= xmalloc (len
+ 1);
312 memcpy (dup
+ 2, opt
+ 5, len
- 2 + 1);
317 opt_index
= find_opt (opt
+ 1, lang_mask
| CL_COMMON
);
318 if (opt_index
== cl_options_count
)
321 option
= &cl_options
[opt_index
];
323 /* Reject negative form of switches that don't take negatives as
325 if (!value
&& (option
->flags
& CL_REJECT_NEGATIVE
))
328 /* We've recognized this switch. */
331 /* Sort out any argument the switch takes. */
332 if (option
->flags
& CL_JOINED
)
334 /* Have arg point to the original switch. This is because
335 some code, such as disable_builtin_function, expects its
336 argument to be persistent until the program exits. */
337 arg
= argv
[0] + cl_options
[opt_index
].opt_len
+ 1;
339 arg
+= strlen ("no-");
341 if (*arg
== '\0' && !(option
->flags
& CL_MISSING_OK
))
343 if (option
->flags
& CL_SEPARATE
)
349 /* Missing argument. */
353 else if (option
->flags
& CL_SEPARATE
)
359 /* Now we've swallowed any potential argument, complain if this
360 is a switch for a different front end. */
361 if (!(option
->flags
& (lang_mask
| CL_COMMON
)))
363 complain_wrong_lang (argv
[0], option
, lang_mask
);
367 if (arg
== NULL
&& (option
->flags
& (CL_JOINED
| CL_SEPARATE
)))
369 if (!(*lang_hooks
.missing_argument
) (opt
, opt_index
))
370 error ("missing argument to \"%s\"", opt
);
374 /* If the switch takes an integer, convert it. */
375 if (arg
&& (option
->flags
& CL_UINTEGER
))
377 value
= integral_argument (arg
);
380 error ("argument to \"%s\" should be a non-negative integer",
386 if (option
->flags
& lang_mask
)
387 if ((*lang_hooks
.handle_option
) (opt_index
, arg
, value
) == 0)
390 if (result
&& (option
->flags
& CL_COMMON
))
391 if (common_handle_option (opt_index
, arg
, value
) == 0)
400 /* Decode and handle the vector of command line options. LANG_MASK
401 contains has a single bit set representing the current
404 handle_options (unsigned int argc
, const char **argv
, unsigned int lang_mask
)
408 for (i
= 1; i
< argc
; i
+= n
)
410 const char *opt
= argv
[i
];
412 /* Interpret "-" or a non-switch as a file name. */
413 if (opt
[0] != '-' || opt
[1] == '\0')
415 main_input_filename
= opt
;
416 (*lang_hooks
.handle_filename
) (opt
);
421 n
= handle_option (argv
+ i
, lang_mask
);
426 error ("unrecognized command line option \"%s\"", opt
);
431 /* Parse command line options and set default flag values. Do minimal
432 options processing. */
434 decode_options (unsigned int argc
, const char **argv
)
436 unsigned int i
, lang_mask
;
438 /* Perform language-specific options initialization. */
439 lang_mask
= (*lang_hooks
.init_options
) (argc
, argv
);
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 const 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 enum opt_code code
= (enum opt_code
) scode
;
619 exit_after_options
= true;
626 case OPT__target_help
:
627 display_target_options ();
628 exit_after_options
= true;
632 print_version (stderr
, "");
633 exit_after_options
= true;
637 g_switch_value
= value
;
643 /* Currently handled in a prescan. */
647 /* For backward compatibility, -W is the same as -Wextra. */
651 case OPT_Waggregate_return
:
652 warn_aggregate_return
= value
;
655 case OPT_Wcast_align
:
656 warn_cast_align
= value
;
659 case OPT_Wdeprecated_declarations
:
660 warn_deprecated_decl
= value
;
663 case OPT_Wdisabled_optimization
:
664 warn_disabled_optimization
= value
;
668 warnings_are_errors
= value
;
679 case OPT_Wlarger_than_
:
680 larger_than_size
= value
;
681 warn_larger_than
= value
!= -1;
684 case OPT_Wmissing_noreturn
:
685 warn_missing_noreturn
= value
;
700 case OPT_Wstrict_aliasing
:
701 warn_strict_aliasing
= value
;
708 case OPT_Wswitch_default
:
709 warn_switch_default
= value
;
712 case OPT_Wswitch_enum
:
713 warn_switch_enum
= value
;
716 case OPT_Wsystem_headers
:
717 warn_system_headers
= value
;
720 case OPT_Wuninitialized
:
721 warn_uninitialized
= value
;
724 case OPT_Wunreachable_code
:
725 warn_notreached
= value
;
732 case OPT_Wunused_function
:
733 warn_unused_function
= value
;
736 case OPT_Wunused_label
:
737 warn_unused_label
= value
;
740 case OPT_Wunused_parameter
:
741 warn_unused_parameter
= value
;
744 case OPT_Wunused_value
:
745 warn_unused_value
= value
;
748 case OPT_Wunused_variable
:
749 warn_unused_variable
= value
;
754 aux_info_file_name
= arg
;
755 flag_gen_aux_info
= 1;
762 case OPT_auxbase_strip
:
764 char *tmp
= xstrdup (arg
);
765 strip_off_ending (tmp
, strlen (tmp
));
772 decode_d_option (arg
);
776 dump_base_name
= arg
;
780 flag_pic
= value
+ value
;
784 flag_pie
= value
+ value
;
787 case OPT_falign_functions
:
788 align_functions
= !value
;
791 case OPT_falign_functions_
:
792 align_functions
= value
;
795 case OPT_falign_jumps
:
796 align_jumps
= !value
;
799 case OPT_falign_jumps_
:
803 case OPT_falign_labels
:
804 align_labels
= !value
;
807 case OPT_falign_labels_
:
808 align_labels
= value
;
811 case OPT_falign_loops
:
812 align_loops
= !value
;
815 case OPT_falign_loops_
:
819 case OPT_fargument_alias
:
820 flag_argument_noalias
= !value
;
823 case OPT_fargument_noalias
:
824 flag_argument_noalias
= value
;
827 case OPT_fargument_noalias_global
:
828 flag_argument_noalias
= value
+ value
;
831 case OPT_fasynchronous_unwind_tables
:
832 flag_asynchronous_unwind_tables
= value
;
835 case OPT_fbounds_check
:
836 flag_bounds_check
= value
;
839 case OPT_fbranch_count_reg
:
840 flag_branch_on_count_reg
= value
;
843 case OPT_fbranch_probabilities
:
844 flag_branch_probabilities
= value
;
847 case OPT_fbranch_target_load_optimize
:
848 flag_branch_target_load_optimize
= value
;
851 case OPT_fbranch_target_load_optimize2
:
852 flag_branch_target_load_optimize2
= value
;
855 case OPT_fcall_used_
:
856 fix_register (arg
, 0, 1);
859 case OPT_fcall_saved_
:
860 fix_register (arg
, 0, 0);
863 case OPT_fcaller_saves
:
864 flag_caller_saves
= value
;
868 flag_no_common
= !value
;
871 case OPT_fcprop_registers
:
872 flag_cprop_registers
= value
;
875 case OPT_fcrossjumping
:
876 flag_crossjumping
= value
;
879 case OPT_fcse_follow_jumps
:
880 flag_cse_follow_jumps
= value
;
883 case OPT_fcse_skip_blocks
:
884 flag_cse_skip_blocks
= value
;
887 case OPT_fdata_sections
:
888 flag_data_sections
= value
;
892 flag_defer_pop
= value
;
895 case OPT_fdelayed_branch
:
896 flag_delayed_branch
= value
;
899 case OPT_fdelete_null_pointer_checks
:
900 flag_delete_null_pointer_checks
= value
;
903 case OPT_fdiagnostics_show_location_
:
904 if (!strcmp (arg
, "once"))
905 diagnostic_prefixing_rule (global_dc
) = DIAGNOSTICS_SHOW_PREFIX_ONCE
;
906 else if (!strcmp (arg
, "every-line"))
907 diagnostic_prefixing_rule (global_dc
)
908 = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE
;
913 case OPT_fdump_unnumbered
:
914 flag_dump_unnumbered
= value
;
917 case OPT_feliminate_dwarf2_dups
:
918 flag_eliminate_dwarf2_dups
= value
;
921 case OPT_feliminate_unused_debug_types
:
922 flag_eliminate_unused_debug_types
= value
;
925 case OPT_feliminate_unused_debug_symbols
:
926 flag_debug_only_used_symbols
= value
;
929 case OPT_fexceptions
:
930 flag_exceptions
= value
;
933 case OPT_fexpensive_optimizations
:
934 flag_expensive_optimizations
= value
;
938 set_fast_math_flags (value
);
941 case OPT_ffinite_math_only
:
942 flag_finite_math_only
= value
;
946 fix_register (arg
, 1, 1);
949 case OPT_ffunction_cse
:
950 flag_no_function_cse
= !value
;
953 case OPT_ffloat_store
:
954 flag_float_store
= value
;
957 case OPT_fforce_addr
:
958 flag_force_addr
= value
;
962 flag_force_mem
= value
;
965 case OPT_ffunction_sections
:
966 flag_function_sections
= value
;
974 flag_gcse_lm
= value
;
978 flag_gcse_sm
= value
;
981 case OPT_fgnu_linker
:
982 flag_gnu_linker
= value
;
985 case OPT_fguess_branch_probability
:
986 flag_guess_branch_prob
= value
;
990 flag_no_ident
= !value
;
993 case OPT_fif_conversion
:
994 flag_if_conversion
= value
;
997 case OPT_fif_conversion2
:
998 flag_if_conversion2
= value
;
1001 case OPT_finhibit_size_directive
:
1002 flag_inhibit_size_directive
= value
;
1006 flag_no_inline
= !value
;
1009 case OPT_finline_functions
:
1010 flag_inline_functions
= value
;
1013 case OPT_finline_limit_
:
1014 case OPT_finline_limit_eq
:
1015 set_param_value ("max-inline-insns", value
);
1016 set_param_value ("max-inline-insns-single", value
/ 2);
1017 set_param_value ("max-inline-insns-auto", value
/ 2);
1018 set_param_value ("max-inline-insns-rtl", value
);
1019 if (value
/ 4 < MIN_INLINE_INSNS
)
1022 set_param_value ("min-inline-insns", value
/ 4);
1024 set_param_value ("min-inline-insns", 10);
1028 case OPT_finstrument_functions
:
1029 flag_instrument_function_entry_exit
= value
;
1032 case OPT_fkeep_inline_functions
:
1033 flag_keep_inline_functions
=value
;
1036 case OPT_fkeep_static_consts
:
1037 flag_keep_static_consts
= value
;
1040 case OPT_fleading_underscore
:
1041 flag_leading_underscore
= value
;
1044 case OPT_floop_optimize
:
1045 flag_loop_optimize
= value
;
1048 case OPT_fmath_errno
:
1049 flag_errno_math
= value
;
1052 case OPT_fmem_report
:
1056 case OPT_fmerge_all_constants
:
1057 flag_merge_constants
= value
+ value
;
1060 case OPT_fmerge_constants
:
1061 flag_merge_constants
= value
;
1064 case OPT_fmessage_length_
:
1065 output_set_maximum_length (&global_dc
->buffer
, value
);
1068 case OPT_fmove_all_movables
:
1069 flag_move_all_movables
= value
;
1073 flag_new_regalloc
= value
;
1076 case OPT_fnon_call_exceptions
:
1077 flag_non_call_exceptions
= value
;
1080 case OPT_fold_unroll_all_loops
:
1081 flag_old_unroll_all_loops
= value
;
1084 case OPT_fold_unroll_loops
:
1085 flag_old_unroll_loops
= value
;
1088 case OPT_fomit_frame_pointer
:
1089 flag_omit_frame_pointer
= value
;
1092 case OPT_foptimize_register_move
:
1093 flag_regmove
= value
;
1096 case OPT_foptimize_sibling_calls
:
1097 flag_optimize_sibling_calls
= value
;
1100 case OPT_fpack_struct
:
1101 flag_pack_struct
= value
;
1104 case OPT_fpeel_loops
:
1105 flag_peel_loops
= value
;
1108 case OPT_fpcc_struct_return
:
1109 flag_pcc_struct_return
= value
;
1113 flag_no_peephole
= !value
;
1116 case OPT_fpeephole2
:
1117 flag_peephole2
= value
;
1128 case OPT_fprefetch_loop_arrays
:
1129 flag_prefetch_loop_arrays
= value
;
1133 profile_flag
= value
;
1136 case OPT_fprofile_arcs
:
1137 profile_arc_flag
= value
;
1140 case OPT_frandom_seed
:
1141 /* The real switch is -fno-random-seed. */
1144 flag_random_seed
= NULL
;
1147 case OPT_frandom_seed_
:
1148 flag_random_seed
= arg
;
1151 case OPT_freduce_all_givs
:
1152 flag_reduce_all_givs
= value
;
1155 case OPT_freg_struct_return
:
1156 flag_pcc_struct_return
= !value
;
1160 flag_regmove
= value
;
1163 case OPT_frename_registers
:
1164 flag_rename_registers
= value
;
1167 case OPT_freorder_blocks
:
1168 flag_reorder_blocks
= value
;
1171 case OPT_freorder_functions
:
1172 flag_reorder_functions
= value
;
1175 case OPT_frerun_cse_after_loop
:
1176 flag_rerun_cse_after_loop
= value
;
1179 case OPT_frerun_loop_opt
:
1180 flag_rerun_loop_opt
= value
;
1183 case OPT_fsched_interblock
:
1184 flag_schedule_interblock
= value
;
1187 case OPT_fsched_spec
:
1188 flag_schedule_speculative
= value
;
1191 case OPT_fsched_spec_load
:
1192 flag_schedule_speculative_load
= value
;
1195 case OPT_fsched_spec_load_dangerous
:
1196 flag_schedule_speculative_load_dangerous
= value
;
1199 case OPT_fsched_verbose_
:
1200 #ifdef INSN_SCHEDULING
1201 fix_sched_param ("verbose", arg
);
1207 case OPT_fsched2_use_superblocks
:
1208 flag_sched2_use_superblocks
= value
;
1211 case OPT_fsched2_use_traces
:
1212 flag_sched2_use_traces
= value
;
1215 case OPT_fschedule_insns
:
1216 flag_schedule_insns
= value
;
1219 case OPT_fschedule_insns2
:
1220 flag_schedule_insns_after_reload
= value
;
1223 case OPT_fshared_data
:
1224 flag_shared_data
= value
;
1227 case OPT_fsignaling_nans
:
1228 flag_signaling_nans
= value
;
1231 case OPT_fsingle_precision_constant
:
1232 flag_single_precision_constant
= value
;
1240 flag_ssa_ccp
= value
;
1244 flag_ssa_dce
= value
;
1247 case OPT_fstack_check
:
1248 flag_stack_check
= value
;
1251 case OPT_fstack_limit
:
1252 /* The real switch is -fno-stack-limit. */
1255 stack_limit_rtx
= NULL_RTX
;
1258 case OPT_fstack_limit_register_
:
1260 int reg
= decode_reg_name (arg
);
1262 error ("unrecognized register name \"%s\"", arg
);
1264 stack_limit_rtx
= gen_rtx_REG (Pmode
, reg
);
1268 case OPT_fstack_limit_symbol_
:
1269 stack_limit_rtx
= gen_rtx_SYMBOL_REF (Pmode
, ggc_strdup (arg
));
1272 case OPT_fstrength_reduce
:
1273 flag_strength_reduce
= value
;
1276 case OPT_fstrict_aliasing
:
1277 flag_strict_aliasing
= value
;
1280 case OPT_fsyntax_only
:
1281 flag_syntax_only
= value
;
1284 case OPT_ftest_coverage
:
1285 flag_test_coverage
= value
;
1288 case OPT_fthread_jumps
:
1289 flag_thread_jumps
= value
;
1292 case OPT_ftime_report
:
1293 time_report
= value
;
1296 case OPT_ftls_model_
:
1297 if (!strcmp (arg
, "global-dynamic"))
1298 flag_tls_default
= TLS_MODEL_GLOBAL_DYNAMIC
;
1299 else if (!strcmp (arg
, "local-dynamic"))
1300 flag_tls_default
= TLS_MODEL_LOCAL_DYNAMIC
;
1301 else if (!strcmp (arg
, "initial-exec"))
1302 flag_tls_default
= TLS_MODEL_INITIAL_EXEC
;
1303 else if (!strcmp (arg
, "local-exec"))
1304 flag_tls_default
= TLS_MODEL_LOCAL_EXEC
;
1306 warning ("unknown tls-model \"%s\"", arg
);
1310 flag_tracer
= value
;
1313 case OPT_ftrapping_math
:
1314 flag_trapping_math
= value
;
1321 case OPT_funit_at_a_time
:
1322 flag_unit_at_a_time
= value
;
1325 case OPT_funroll_all_loops
:
1326 flag_unroll_all_loops
= value
;
1329 case OPT_funroll_loops
:
1330 flag_unroll_loops
= value
;
1333 case OPT_funsafe_math_optimizations
:
1334 flag_unsafe_math_optimizations
= value
;
1337 case OPT_funswitch_loops
:
1338 flag_unswitch_loops
= value
;
1341 case OPT_funwind_tables
:
1342 flag_unwind_tables
= value
;
1345 case OPT_fverbose_asm
:
1346 flag_verbose_asm
= value
;
1353 case OPT_fwritable_strings
:
1354 flag_writable_strings
= value
;
1357 case OPT_fzero_initialized_in_bss
:
1358 flag_zero_initialized_in_bss
= value
;
1362 decode_g_option (arg
);
1366 set_target_switch (arg
);
1370 asm_file_name
= arg
;
1381 case OPT_pedantic_errors
:
1382 flag_pedantic_errors
= pedantic
= 1;
1394 inhibit_warnings
= true;
1401 /* Handle --param NAME=VALUE. */
1403 handle_param (const char *carg
)
1408 arg
= xstrdup (carg
);
1409 equal
= strchr (arg
, '=');
1411 error ("%s: --param arguments should be of the form NAME=VALUE", arg
);
1414 value
= integral_argument (equal
+ 1);
1416 error ("invalid --param value `%s'", equal
+ 1);
1420 set_param_value (arg
, value
);
1427 /* Handle -W and -Wextra. */
1429 set_Wextra (int setting
)
1431 extra_warnings
= setting
;
1432 warn_unused_value
= setting
;
1433 warn_unused_parameter
= (setting
&& maybe_warn_unused_parameter
);
1435 /* We save the value of warn_uninitialized, since if they put
1436 -Wuninitialized on the command line, we need to generate a
1437 warning about not using it without also specifying -O. */
1439 warn_uninitialized
= 0;
1440 else if (warn_uninitialized
!= 1)
1441 warn_uninitialized
= 2;
1444 /* Initialize unused warning flags. */
1446 set_Wunused (int setting
)
1448 warn_unused_function
= setting
;
1449 warn_unused_label
= setting
;
1450 /* Unused function parameter warnings are reported when either
1451 ``-Wextra -Wunused'' or ``-Wunused-parameter'' is specified.
1452 Thus, if -Wextra has already been seen, set warn_unused_parameter;
1453 otherwise set maybe_warn_extra_parameter, which will be picked up
1455 maybe_warn_unused_parameter
= setting
;
1456 warn_unused_parameter
= (setting
&& extra_warnings
);
1457 warn_unused_variable
= setting
;
1458 warn_unused_value
= setting
;
1461 /* The following routines are useful in setting all the flags that
1462 -ffast-math and -fno-fast-math imply. */
1464 set_fast_math_flags (int set
)
1466 flag_trapping_math
= !set
;
1467 flag_unsafe_math_optimizations
= set
;
1468 flag_finite_math_only
= set
;
1469 flag_errno_math
= !set
;
1471 flag_signaling_nans
= 0;
1474 /* Return true iff flags are set as if -ffast-math. */
1476 fast_math_flags_set_p (void)
1478 return (!flag_trapping_math
1479 && flag_unsafe_math_optimizations
1480 && flag_finite_math_only
1481 && !flag_errno_math
);
1484 /* Output --help text. */
1490 puts (_("\nThe following options are language-independent:\n"));
1492 for (i
= 0; i
< cl_options_count
; i
++)
1494 const char *help
= cl_options
[i
].help
;
1495 const char *opt
, *tab
;
1497 /* During transition, ignore switches with no help. */
1501 /* Get the translation. */
1504 tab
= strchr (help
, '\t');
1513 opt
= cl_options
[i
].opt_text
;
1517 wrap_help (help
, opt
, len
);
1524 /* Output ITEM, of length ITEM_WIDTH, in the left column, followed by
1525 word-wrapped HELP in a second column. */
1527 wrap_help (const char *help
, const char *item
, int item_width
)
1529 const int columns
= 80, col_width
= 27;
1530 unsigned int remaining
, room
, len
;
1532 remaining
= strlen (help
);
1536 room
= columns
- 3 - MAX (col_width
, item_width
);
1543 for (i
= 0; help
[i
]; i
++)
1545 if (i
>= room
&& len
!= remaining
)
1549 else if (help
[i
] == '-')
1554 printf( " %-*.*s %.*s\n", col_width
, item_width
, item
, len
, help
);
1556 while (help
[len
] == ' ')