c-common.h (c_comon_handle_filename, [...]): New.
[platform/upstream/gcc.git] / gcc / opts.c
1 /* Command line option handling.
2    Copyright (C) 2002, 2003 Free Software Foundation, Inc.
3    Contributed by Neil Booth.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING.  If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA.  */
21
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "tree.h"
27 #include "rtl.h"
28 #include "ggc.h"
29 #include "output.h"
30 #include "langhooks.h"
31 #include "opts.h"
32 #include "options.h"
33 #include "flags.h"
34 #include "toplev.h"
35 #include "params.h"
36 #include "diagnostic.h"
37 #include "tm_p.h"               /* For OPTIMIZATION_OPTIONS.  */
38 #include "insn-attr.h"          /* For INSN_SCHEDULING.  */
39
40 /* Value of the -G xx switch, and whether it was passed or not.  */
41 unsigned HOST_WIDE_INT g_switch_value;
42 bool g_switch_set;
43
44 /* True if we should exit after parsing options.  */
45 bool exit_after_options;
46
47 /* If -version.  */
48 bool version_flag;
49
50 /* Print various extra warnings.  -W/-Wextra.  */
51 bool extra_warnings;
52
53 /* Don't print warning messages.  -w.  */
54 bool inhibit_warnings;
55
56 /* Treat warnings as errors.  -Werror.  */
57 bool warnings_are_errors;
58
59 /* Warn if a function returns an aggregate, since there are often
60    incompatible calling conventions for doing this.  */
61 bool warn_aggregate_return;
62
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).  */
66 bool warn_cast_align;
67
68 /* Nonzero means warn about uses of __attribute__((deprecated))
69    declarations.  */
70 bool warn_deprecated_decl = true;
71
72 /* Warn when an optimization pass is disabled.  */
73 bool warn_disabled_optimization;
74
75 /* Nonzero means warn if inline function is too large.  */
76 bool warn_inline;
77
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;
83
84 /* Warn about functions which might be candidates for attribute noreturn.  */
85 bool warn_missing_noreturn;
86
87 /* True to warn about code which is never reached.  */
88 bool warn_notreached;
89
90 /* Warn if packed attribute on struct is unnecessary and inefficient.  */
91 bool warn_packed;
92
93 /* Warn when gcc pads a structure to an alignment boundary.  */
94 bool warn_padded;
95
96 /* True means warn about all declarations which shadow others.  */
97 bool warn_shadow;
98
99 /* Nonzero means warn about constructs which might not be
100    strict-aliasing safe.  */
101 bool warn_strict_aliasing;
102
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.  */
105 bool warn_switch;
106
107 /* Warn if a switch does not have a default case.  */
108 bool warn_switch_default;
109
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;
113
114 /* Don't suppress warnings from system headers.  -Wsystem-headers.  */
115 bool warn_system_headers;
116
117 /* True to warn about variables used before they are initialized.  */
118 int warn_uninitialized;
119
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;
126
127 /* Hack for cooperation between set_Wunused and set_Wextra.  */
128 static bool maybe_warn_unused_parameter;
129
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);
139
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.
143
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".
148
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).
159
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.  */
164 static size_t
165 find_opt (const char *input, int lang_mask)
166 {
167   size_t mn, mx, md, opt_len;
168   size_t match_wrong_lang;
169   int comp;
170
171   mn = 0;
172   mx = cl_options_count;
173
174   /* Find mn such this lexicographical inequality holds:
175      cl_options[mn] <= input < cl_options[mn + 1].  */
176   while (mx - mn > 1)
177     {
178       md = (mn + mx) / 2;
179       opt_len = cl_options[md].opt_len;
180       comp = strncmp (input, cl_options[md].opt_text, opt_len);
181
182       if (comp < 0)
183         mx = md;
184       else
185         mn = md;
186     }
187
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;
191
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.  */
195   do
196     {
197       const struct cl_option *opt = &cl_options[mn];
198
199       /* Is this switch a prefix of the input?  */
200       if (!strncmp (input, opt->opt_text, opt->opt_len))
201         {
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)))
206             return mn;
207
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;
212         }
213
214       /* Try the next possibility.  This is cl_options_count if there
215          are no more.  */
216       mn = opt->back_chain;
217     }
218   while (mn != cl_options_count);
219
220   /* Return the best wrong match, or cl_options_count if none.  */
221   return match_wrong_lang;
222 }
223
224 /* If ARG is a non-negative integer made up solely of digits, return its
225    value, otherwise return -1.  */
226 static int
227 integral_argument (const char *arg)
228 {
229   const char *p = arg;
230
231   while (*p && ISDIGIT (*p))
232     p++;
233
234   if (*p == '\0')
235     return atoi (arg);
236
237   return -1;
238 }
239
240 /* Return a malloced slash-separated list of languages in MASK.  */
241 static char *
242 write_langs (unsigned int mask)
243 {
244   unsigned int n = 0, len = 0;
245   const char *lang_name;
246   char *result;
247
248   for (n = 0; (lang_name = lang_names[n]) != 0; n++)
249     if (mask & (1U << n))
250       len += strlen (lang_name) + 1;
251
252   result = xmalloc (len);
253   len = 0;
254   for (n = 0; (lang_name = lang_names[n]) != 0; n++)
255     if (mask & (1U << n))
256       {
257         if (len)
258           result[len++] = '/';
259         strcpy (result + len, lang_name);
260         len += strlen (lang_name);
261       }
262
263   result[len] = 0;
264
265   return result;
266 }
267
268 /* Complain that switch OPT_INDEX does not apply to this front end.  */
269 static void
270 complain_wrong_lang (const char *text, const struct cl_option *option,
271                      unsigned int lang_mask)
272 {
273   char *ok_langs, *bad_lang;
274
275   ok_langs = write_langs (option->flags);
276   bad_lang = write_langs (lang_mask);
277
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);
281
282   free (ok_langs);
283   free (bad_lang);
284 }
285
286 /* Handle the switch beginning at ARGV for the language indicated by
287    LANG_MASK.  Returns the number of switches consumed.  */
288 static unsigned int
289 handle_option (const char **argv, unsigned int lang_mask)
290 {
291   size_t opt_index;
292   const char *opt, *arg = 0;
293   char *dup = 0;
294   int value = 1;
295   unsigned int result = 0;
296   const struct cl_option *option;
297
298   opt = argv[0];
299
300   /* Drop the "no-" from negative switches.  */
301   if ((opt[1] == 'W' || opt[1] == 'f')
302       && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
303     {
304       size_t len = strlen (opt) - 3;
305
306       dup = xmalloc (len + 1);
307       dup[0] = '-';
308       dup[1] = opt[1];
309       memcpy (dup + 2, opt + 5, len - 2 + 1);
310       opt = dup;
311       value = 0;
312     }
313
314   opt_index = find_opt (opt + 1, lang_mask | CL_COMMON);
315   if (opt_index == cl_options_count)
316     goto done;
317
318   option = &cl_options[opt_index];
319
320   /* Reject negative form of switches that don't take negatives as
321      unrecognized.  */
322   if (!value && (option->flags & CL_REJECT_NEGATIVE))
323     goto done;
324
325   /* We've recognized this switch.  */
326   result = 1;
327
328   /* Sort out any argument the switch takes.  */
329   if (option->flags & CL_JOINED)
330     {
331       /* Have arg point to the original switch.  This is because
332          some code, such as disable_builtin_function, expects its
333          argument to be persistent until the program exits.  */
334       arg = argv[0] + cl_options[opt_index].opt_len + 1;
335       if (!value)
336         arg += strlen ("no-");
337
338       if (*arg == '\0' && !(option->flags & CL_MISSING_OK))
339         {
340           if (option->flags & CL_SEPARATE)
341             {
342               arg = argv[1];
343               result = 2;
344             }
345           else
346             /* Missing argument.  */
347             arg = NULL;
348         }
349     }
350   else if (option->flags & CL_SEPARATE)
351     {
352       arg = argv[1];
353       result = 2;
354     }
355
356   /* Now we've swallowed any potential argument, complain if this
357      is a switch for a different front end.  */
358   if (!(option->flags & (lang_mask | CL_COMMON)))
359     {
360       complain_wrong_lang (argv[0], option, lang_mask);
361       goto done;
362     }
363
364   if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE)))
365     {
366       if (!(*lang_hooks.missing_argument) (opt, opt_index))
367         error ("missing argument to \"%s\"", opt);
368       goto done;
369     }
370
371   /* If the switch takes an integer, convert it.  */
372   if (arg && (option->flags & CL_UINTEGER))
373     {
374       value = integral_argument (arg);
375       if (value == -1)
376         {
377           error ("argument to \"-%s\" should be a non-negative integer",
378                  option->opt_text);
379           goto done;
380         }
381     }
382
383   if (option->flags & lang_mask)
384     if ((*lang_hooks.handle_option) (opt_index, arg, value) == 0)
385       result = 0;
386
387   if (result && (option->flags & CL_COMMON))
388     if (common_handle_option (opt_index, arg, value) == 0)
389       result = 0;
390
391  done:
392   if (dup)
393     free (dup);
394   return result;
395 }
396
397 /* Decode and handle the vector of command line options.  LANG_MASK
398    contains has a single bit set representing the current
399    language.  */
400 static void
401 handle_options (unsigned int argc, const char **argv, unsigned int lang_mask)
402 {
403   unsigned int n, i;
404
405   for (i = 1; i < argc; i += n)
406     {
407       const char *opt = argv[i];
408
409       /* Interpret "-" or a non-switch as a file name.  */
410       if (opt[0] != '-' || opt[1] == '\0')
411         {
412           main_input_filename = opt;
413           (*lang_hooks.handle_filename) (opt);
414           n = 1;
415           continue;
416         }
417
418       n = handle_option (argv + i, lang_mask);
419
420       if (!n)
421         {
422           n = 1;
423           error ("unrecognized command line option \"%s\"", opt);
424         }
425     }
426 }
427
428 /* Parse command line options and set default flag values.  Do minimal
429    options processing.  */
430 void
431 decode_options (unsigned int argc, const char **argv)
432 {
433   unsigned int i, lang_mask;
434
435   /* Perform language-specific options initialization.  */
436   lang_mask = (*lang_hooks.init_options) (argc, argv);
437
438   /* Scan to see what optimization level has been specified.  That will
439      determine the default value of many flags.  */
440   for (i = 1; i < argc; i++)
441     {
442       if (!strcmp (argv[i], "-O"))
443         {
444           optimize = 1;
445           optimize_size = 0;
446         }
447       else if (argv[i][0] == '-' && argv[i][1] == 'O')
448         {
449           /* Handle -Os, -O2, -O3, -O69, ...  */
450           const char *p = &argv[i][2];
451
452           if ((p[0] == 's') && (p[1] == 0))
453             {
454               optimize_size = 1;
455
456               /* Optimizing for size forces optimize to be 2.  */
457               optimize = 2;
458             }
459           else
460             {
461               const int optimize_val = read_integral_parameter (p, p - 2, -1);
462               if (optimize_val != -1)
463                 {
464                   optimize = optimize_val;
465                   optimize_size = 0;
466                 }
467             }
468         }
469     }
470
471   if (!optimize)
472     {
473       flag_merge_constants = 0;
474     }
475
476   if (optimize >= 1)
477     {
478       flag_defer_pop = 1;
479       flag_thread_jumps = 1;
480 #ifdef DELAY_SLOTS
481       flag_delayed_branch = 1;
482 #endif
483 #ifdef CAN_DEBUG_WITHOUT_FP
484       flag_omit_frame_pointer = 1;
485 #endif
486       flag_guess_branch_prob = 1;
487       flag_cprop_registers = 1;
488       flag_loop_optimize = 1;
489       flag_crossjumping = 1;
490       flag_if_conversion = 1;
491       flag_if_conversion2 = 1;
492     }
493
494   if (optimize >= 2)
495     {
496       flag_optimize_sibling_calls = 1;
497       flag_cse_follow_jumps = 1;
498       flag_cse_skip_blocks = 1;
499       flag_gcse = 1;
500       flag_expensive_optimizations = 1;
501       flag_strength_reduce = 1;
502       flag_rerun_cse_after_loop = 1;
503       flag_rerun_loop_opt = 1;
504       flag_caller_saves = 1;
505       flag_force_mem = 1;
506       flag_peephole2 = 1;
507 #ifdef INSN_SCHEDULING
508       flag_schedule_insns = 1;
509       flag_schedule_insns_after_reload = 1;
510 #endif
511       flag_regmove = 1;
512       flag_strict_aliasing = 1;
513       flag_delete_null_pointer_checks = 1;
514       flag_reorder_blocks = 1;
515       flag_reorder_functions = 1;
516     }
517
518   if (optimize >= 3)
519     {
520       flag_inline_functions = 1;
521       flag_rename_registers = 1;
522       flag_unswitch_loops = 1;
523       flag_unit_at_a_time = 1;
524     }
525
526   if (optimize < 2 || optimize_size)
527     {
528       align_loops = 1;
529       align_jumps = 1;
530       align_labels = 1;
531       align_functions = 1;
532
533       /* Don't reorder blocks when optimizing for size because extra
534          jump insns may be created; also barrier may create extra padding.
535
536          More correctly we should have a block reordering mode that tried
537          to minimize the combined size of all the jumps.  This would more
538          or less automatically remove extra jumps, but would also try to
539          use more short jumps instead of long jumps.  */
540       flag_reorder_blocks = 0;
541     }
542
543   /* Initialize whether `char' is signed.  */
544   flag_signed_char = DEFAULT_SIGNED_CHAR;
545 #ifdef DEFAULT_SHORT_ENUMS
546   /* Initialize how much space enums occupy, by default.  */
547   flag_short_enums = DEFAULT_SHORT_ENUMS;
548 #endif
549
550   /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
551      modify it.  */
552   target_flags = 0;
553   set_target_switch ("");
554
555   /* Unwind tables are always present in an ABI-conformant IA-64
556      object file, so the default should be ON.  */
557 #ifdef IA64_UNWIND_INFO
558   flag_unwind_tables = IA64_UNWIND_INFO;
559 #endif
560
561 #ifdef OPTIMIZATION_OPTIONS
562   /* Allow default optimizations to be specified on a per-machine basis.  */
563   OPTIMIZATION_OPTIONS (optimize, optimize_size);
564 #endif
565
566   handle_options (argc, argv, lang_mask);
567
568   if (flag_pie)
569     flag_pic = flag_pie;
570   if (flag_pic && !flag_pie)
571     flag_shlib = 1;
572
573   if (flag_no_inline == 2)
574     flag_no_inline = 0;
575   else
576     flag_really_no_inline = flag_no_inline;
577
578   /* Set flag_no_inline before the post_options () hook.  The C front
579      ends use it to determine tree inlining defaults.  FIXME: such
580      code should be lang-independent when all front ends use tree
581      inlining, in which case it, and this condition, should be moved
582      to the top of process_options() instead.  */
583   if (optimize == 0)
584     {
585       /* Inlining does not work if not optimizing,
586          so force it not to be done.  */
587       flag_no_inline = 1;
588       warn_inline = 0;
589
590       /* The c_decode_option function and decode_option hook set
591          this to `2' if -Wall is used, so we can avoid giving out
592          lots of errors for people who don't realize what -Wall does.  */
593       if (warn_uninitialized == 1)
594         warning ("-Wuninitialized is not supported without -O");
595     }
596
597   if (flag_really_no_inline == 2)
598     flag_really_no_inline = flag_no_inline;
599 }
600
601 /* Handle target- and language-independent options.  Return zero to
602    generate an "unknown option" message.  */
603 static int
604 common_handle_option (size_t scode, const char *arg,
605                       int value ATTRIBUTE_UNUSED)
606 {
607   enum opt_code code = (enum opt_code) scode;
608
609   switch (code)
610     {
611     default:
612       abort ();
613
614     case OPT__help:
615       display_help ();
616       exit_after_options = true;
617       break;
618
619     case OPT__param:
620       handle_param (arg);
621       break;
622
623     case OPT__target_help:
624       display_target_options ();
625       exit_after_options = true;
626       break;
627
628     case OPT__version:
629       print_version (stderr, "");
630       exit_after_options = true;
631       break;
632
633     case OPT_G:
634       g_switch_value = value;
635       g_switch_set = true;
636       break;
637
638     case OPT_O:
639     case OPT_Os:
640       /* Currently handled in a prescan.  */
641       break;
642
643     case OPT_W:
644       /* For backward compatibility, -W is the same as -Wextra.  */
645       set_Wextra (value);
646       break;
647
648     case OPT_Waggregate_return:
649       warn_aggregate_return = value;
650       break;
651
652     case OPT_Wcast_align:
653       warn_cast_align = value;
654       break;
655
656     case OPT_Wdeprecated_declarations:
657       warn_deprecated_decl = value;
658       break;
659
660     case OPT_Wdisabled_optimization:
661       warn_disabled_optimization = value;
662       break;
663
664     case OPT_Werror:
665       warnings_are_errors = value;
666       break;
667
668     case OPT_Wextra:
669       set_Wextra (value);
670       break;
671
672     case OPT_Winline:
673       warn_inline = value;
674       break;
675
676     case OPT_Wlarger_than_:
677       larger_than_size = value;
678       warn_larger_than = value != -1;
679       break;
680
681     case OPT_Wmissing_noreturn:
682       warn_missing_noreturn = value;
683       break;
684
685     case OPT_Wpacked:
686       warn_packed = value;
687       break;
688
689     case OPT_Wpadded:
690       warn_padded = value;
691       break;
692
693     case OPT_Wshadow:
694       warn_shadow = value;
695       break;
696
697     case OPT_Wstrict_aliasing:
698       warn_strict_aliasing = value;
699       break;
700
701     case OPT_Wswitch:
702       warn_switch = value;
703       break;
704
705     case OPT_Wswitch_default:
706       warn_switch_default = value;
707       break;
708
709     case OPT_Wswitch_enum:
710       warn_switch_enum = value;
711       break;
712
713     case OPT_Wsystem_headers:
714       warn_system_headers = value;
715       break;
716
717     case OPT_Wuninitialized:
718       warn_uninitialized = value;
719       break;
720
721     case OPT_Wunreachable_code:
722       warn_notreached = value;
723       break;
724
725     case OPT_Wunused:
726       set_Wunused (value);
727       break;
728
729     case OPT_Wunused_function:
730       warn_unused_function = value;
731       break;
732
733     case OPT_Wunused_label:
734       warn_unused_label = value;
735       break;
736
737     case OPT_Wunused_parameter:
738       warn_unused_parameter = value;
739       break;
740
741     case OPT_Wunused_value:
742       warn_unused_value = value;
743       break;
744
745     case OPT_Wunused_variable:
746       warn_unused_variable = value;
747       break;
748
749     case OPT_aux_info:
750     case OPT_aux_info_:
751       aux_info_file_name = arg;
752       flag_gen_aux_info = 1;
753       break;
754
755     case OPT_auxbase:
756       aux_base_name = arg;
757       break;
758
759     case OPT_auxbase_strip:
760       {
761         char *tmp = xstrdup (arg);
762         strip_off_ending (tmp, strlen (tmp));
763         if (tmp[0])
764           aux_base_name = tmp;
765       }
766       break;
767
768     case OPT_d:
769       decode_d_option (arg);
770       break;
771
772     case OPT_dumpbase:
773       dump_base_name = arg;
774       break;
775
776     case OPT_fPIC:
777       flag_pic = value + value;
778       break;
779
780     case OPT_fPIE:
781       flag_pie = value + value;
782       break;
783
784     case OPT_falign_functions:
785     case OPT_falign_functions_:
786       align_functions = !value;
787       break;
788
789     case OPT_falign_jumps:
790     case OPT_falign_jumps_:
791       align_jumps = !value;
792       break;
793
794     case OPT_falign_labels:
795     case OPT_falign_labels_:
796       align_labels = !value;
797       break;
798
799     case OPT_falign_loops:
800     case OPT_falign_loops_:
801       align_loops = !value;
802       break;
803
804     case OPT_fargument_alias:
805       flag_argument_noalias = !value;
806       break;
807
808     case OPT_fargument_noalias:
809       flag_argument_noalias = value;
810       break;
811
812     case OPT_fargument_noalias_global:
813       flag_argument_noalias = value + value;
814       break;
815
816     case OPT_fasynchronous_unwind_tables:
817       flag_asynchronous_unwind_tables = value;
818       break;
819
820     case OPT_fbounds_check:
821       flag_bounds_check = value;
822       break;
823
824     case OPT_fbranch_count_reg:
825       flag_branch_on_count_reg = value;
826       break;
827
828     case OPT_fbranch_probabilities:
829       flag_branch_probabilities = value;
830       break;
831
832     case OPT_fbranch_target_load_optimize:
833       flag_branch_target_load_optimize = value;
834       break;
835
836     case OPT_fbranch_target_load_optimize2:
837       flag_branch_target_load_optimize2 = value;
838       break;
839
840     case OPT_fcall_used_:
841       fix_register (arg, 0, 1);
842       break;
843
844     case OPT_fcall_saved_:
845       fix_register (arg, 0, 0);
846       break;
847
848     case OPT_fcaller_saves:
849       flag_caller_saves = value;
850       break;
851
852     case OPT_fcommon:
853       flag_no_common = !value;
854       break;
855
856     case OPT_fcprop_registers:
857       flag_cprop_registers = value;
858       break;
859
860     case OPT_fcrossjumping:
861       flag_crossjumping = value;
862       break;
863
864     case OPT_fcse_follow_jumps:
865       flag_cse_follow_jumps = value;
866       break;
867
868     case OPT_fcse_skip_blocks:
869       flag_cse_skip_blocks = value;
870       break;
871
872     case OPT_fdata_sections:
873       flag_data_sections = value;
874       break;
875
876     case OPT_fdefer_pop:
877       flag_defer_pop = value;
878       break;
879
880     case OPT_fdelayed_branch:
881       flag_delayed_branch = value;
882       break;
883
884     case OPT_fdelete_null_pointer_checks:
885       flag_delete_null_pointer_checks = value;
886       break;
887
888     case OPT_fdiagnostics_show_location_:
889       if (!strcmp (arg, "once"))
890         diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
891       else if (!strcmp (arg, "every-line"))
892         diagnostic_prefixing_rule (global_dc)
893           = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
894       else
895         return 0;
896       break;
897
898     case OPT_fdump_unnumbered:
899       flag_dump_unnumbered = value;
900       break;
901
902     case OPT_feliminate_dwarf2_dups:
903       flag_eliminate_dwarf2_dups = value;
904       break;
905
906     case OPT_feliminate_unused_debug_types:
907       flag_eliminate_unused_debug_types = value;
908       break;
909
910     case OPT_feliminate_unused_debug_symbols:
911       flag_debug_only_used_symbols = value;
912       break;
913
914     case OPT_fexceptions:
915       flag_exceptions = value;
916       break;
917
918     case OPT_fexpensive_optimizations:
919       flag_expensive_optimizations = value;
920       break;
921
922     case OPT_ffast_math:
923       set_fast_math_flags (value);
924       break;
925
926     case OPT_ffinite_math_only:
927       flag_finite_math_only = value;
928       break;
929
930     case OPT_ffixed_:
931       fix_register (arg, 1, 1);
932       break;
933
934     case OPT_ffunction_cse:
935       flag_no_function_cse = !value;
936       break;
937
938     case OPT_ffloat_store:
939       flag_float_store = value;
940       break;
941
942     case OPT_fforce_addr:
943       flag_force_addr = value;
944       break;
945
946     case OPT_fforce_mem:
947       flag_force_mem = value;
948       break;
949
950     case OPT_ffunction_sections:
951       flag_function_sections = value;
952       break;
953
954     case OPT_fgcse:
955       flag_gcse = value;
956       break;
957
958     case OPT_fgcse_lm:
959       flag_gcse_lm = value;
960       break;
961
962     case OPT_fgcse_sm:
963       flag_gcse_sm = value;
964       break;
965
966     case OPT_fgnu_linker:
967       flag_gnu_linker = value;
968       break;
969
970     case OPT_fguess_branch_probability:
971       flag_guess_branch_prob = value;
972       break;
973
974     case OPT_fident:
975       flag_no_ident = !value;
976       break;
977
978     case OPT_fif_conversion:
979       flag_if_conversion = value;
980       break;
981
982     case OPT_fif_conversion2:
983       flag_if_conversion2 = value;
984       break;
985
986     case OPT_finhibit_size_directive:
987       flag_inhibit_size_directive = value;
988       break;
989
990     case OPT_finline:
991       flag_no_inline = !value;
992       break;
993
994     case OPT_finline_functions:
995       flag_inline_functions = value;
996       break;
997
998     case OPT_finline_limit_:
999     case OPT_finline_limit_eq:
1000       set_param_value ("max-inline-insns", value);
1001       set_param_value ("max-inline-insns-single", value / 2);
1002       set_param_value ("max-inline-insns-auto", value / 2);
1003       set_param_value ("max-inline-insns-rtl", value);
1004       if (value / 4 < MIN_INLINE_INSNS)
1005         {
1006           if (value / 4 > 10)
1007             set_param_value ("min-inline-insns", value / 4);
1008           else
1009             set_param_value ("min-inline-insns", 10);
1010         }
1011       break;
1012
1013     case OPT_finstrument_functions:
1014       flag_instrument_function_entry_exit = value;
1015       break;
1016
1017     case OPT_fkeep_inline_functions:
1018       flag_keep_inline_functions =value;
1019       break;
1020
1021     case OPT_fkeep_static_consts:
1022       flag_keep_static_consts = value;
1023       break;
1024
1025     case OPT_fleading_underscore:
1026       flag_leading_underscore = value;
1027       break;
1028
1029     case OPT_floop_optimize:
1030       flag_loop_optimize = value;
1031       break;
1032
1033     case OPT_fmath_errno:
1034       flag_errno_math = value;
1035       break;
1036
1037     case OPT_fmem_report:
1038       mem_report = value;
1039       break;
1040
1041     case OPT_fmerge_all_constants:
1042       flag_merge_constants = value + value;
1043       break;
1044
1045     case OPT_fmerge_constants:
1046       flag_merge_constants = value;
1047       break;
1048
1049     case OPT_fmessage_length_:
1050       output_set_maximum_length (&global_dc->buffer, value);
1051       break;
1052
1053     case OPT_fmove_all_movables:
1054       flag_move_all_movables = value;
1055       break;
1056
1057     case OPT_fnew_ra:
1058       flag_new_regalloc = value;
1059       break;
1060
1061     case OPT_fnon_call_exceptions:
1062       flag_non_call_exceptions = value;
1063       break;
1064
1065     case OPT_fold_unroll_all_loops:
1066       flag_old_unroll_all_loops = value;
1067       break;
1068
1069     case OPT_fold_unroll_loops:
1070       flag_old_unroll_loops = value;
1071       break;
1072
1073     case OPT_fomit_frame_pointer:
1074       flag_omit_frame_pointer = value;
1075       break;
1076
1077     case OPT_foptimize_register_move:
1078       flag_regmove = value;
1079       break;
1080
1081     case OPT_foptimize_sibling_calls:
1082       flag_optimize_sibling_calls = value;
1083       break;
1084
1085     case OPT_fpack_struct:
1086       flag_pack_struct = value;
1087       break;
1088
1089     case OPT_fpeel_loops:
1090       flag_peel_loops = value;
1091       break;
1092
1093     case OPT_fpcc_struct_return:
1094       flag_pcc_struct_return = value;
1095       break;
1096
1097     case OPT_fpeephole:
1098       flag_no_peephole = !value;
1099       break;
1100
1101     case OPT_fpeephole2:
1102       flag_peephole2 = value;
1103       break;
1104
1105     case OPT_fpic:
1106       flag_pic = value;
1107       break;
1108
1109     case OPT_fpie:
1110       flag_pie = value;
1111       break;
1112
1113     case OPT_fprefetch_loop_arrays:
1114       flag_prefetch_loop_arrays = value;
1115       break;
1116
1117     case OPT_fprofile:
1118       profile_flag = value;
1119       break;
1120
1121     case OPT_fprofile_arcs:
1122       profile_arc_flag = value;
1123       break;
1124
1125     case OPT_frandom_seed:
1126       /* The real switch is -fno-random-seed.  */
1127       if (value)
1128         return 0;
1129       flag_random_seed = NULL;
1130       break;
1131
1132     case OPT_frandom_seed_:
1133       flag_random_seed = arg;
1134       break;
1135
1136     case OPT_freduce_all_givs:
1137       flag_reduce_all_givs = value;
1138       break;
1139
1140     case OPT_freg_struct_return:
1141       flag_pcc_struct_return = !value;
1142       break;
1143
1144     case OPT_fregmove:
1145       flag_regmove = value;
1146       break;
1147
1148     case OPT_frename_registers:
1149       flag_rename_registers = value;
1150       break;
1151
1152     case OPT_freorder_blocks:
1153       flag_reorder_blocks = value;
1154       break;
1155
1156     case OPT_freorder_functions:
1157       flag_reorder_functions = value;
1158       break;
1159
1160     case OPT_frerun_cse_after_loop:
1161       flag_rerun_cse_after_loop = value;
1162       break;
1163
1164     case OPT_frerun_loop_opt:
1165       flag_rerun_loop_opt = value;
1166       break;
1167
1168     case OPT_fsched_interblock:
1169       flag_schedule_interblock= value;
1170       break;
1171
1172     case OPT_fsched_spec:
1173       flag_schedule_speculative = value;
1174       break;
1175
1176     case OPT_fsched_spec_load:
1177       flag_schedule_speculative_load = value;
1178       break;
1179
1180     case OPT_fsched_spec_load_dangerous:
1181       flag_schedule_speculative_load_dangerous = value;
1182       break;
1183
1184     case OPT_fsched_verbose_:
1185 #ifdef INSN_SCHEDULING
1186       fix_sched_param ("verbose", arg);
1187       break;
1188 #else
1189       return 0;
1190 #endif
1191
1192     case OPT_fsched2_use_superblocks:
1193       flag_sched2_use_superblocks = value;
1194       break;
1195
1196     case OPT_fsched2_use_traces:
1197       flag_sched2_use_traces = value;
1198       break;
1199
1200     case OPT_fschedule_insns:
1201       flag_schedule_insns = value;
1202       break;
1203
1204     case OPT_fschedule_insns2:
1205       flag_schedule_insns_after_reload = value;
1206       break;
1207
1208     case OPT_fshared_data:
1209       flag_shared_data = value;
1210       break;
1211
1212     case OPT_fsignaling_nans:
1213       flag_signaling_nans = value;
1214       break;
1215
1216     case OPT_fsingle_precision_constant:
1217       flag_single_precision_constant = value;
1218       break;
1219
1220     case OPT_fssa:
1221       flag_ssa = value;
1222       break;
1223
1224     case OPT_fssa_ccp:
1225       flag_ssa_ccp = value;
1226       break;
1227
1228     case OPT_fssa_dce:
1229       flag_ssa_dce = value;
1230       break;
1231
1232     case OPT_fstack_check:
1233       flag_stack_check = value;
1234       break;
1235
1236     case OPT_fstack_limit:
1237       /* The real switch is -fno-stack-limit.  */
1238       if (value)
1239         return 0;
1240       stack_limit_rtx = NULL_RTX;
1241       break;
1242
1243     case OPT_fstack_limit_register_:
1244       {
1245         int reg = decode_reg_name (arg);
1246         if (reg < 0)
1247           error ("unrecognized register name \"%s\"", arg);
1248         else
1249           stack_limit_rtx = gen_rtx_REG (Pmode, reg);
1250       }
1251       break;
1252
1253     case OPT_fstack_limit_symbol_:
1254       stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (arg));
1255       break;
1256
1257     case OPT_fstrength_reduce:
1258       flag_strength_reduce = value;
1259       break;
1260
1261     case OPT_fstrict_aliasing:
1262       flag_strict_aliasing = value;
1263       break;
1264
1265     case OPT_fsyntax_only:
1266       flag_syntax_only = value;
1267       break;
1268
1269     case OPT_ftest_coverage:
1270       flag_test_coverage = value;
1271       break;
1272
1273     case OPT_fthread_jumps:
1274       flag_thread_jumps = value;
1275       break;
1276
1277     case OPT_ftime_report:
1278       time_report = value;
1279       break;
1280
1281     case OPT_ftls_model_:
1282       if (!strcmp (arg, "global-dynamic"))
1283         flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
1284       else if (!strcmp (arg, "local-dynamic"))
1285         flag_tls_default = TLS_MODEL_LOCAL_DYNAMIC;
1286       else if (!strcmp (arg, "initial-exec"))
1287         flag_tls_default = TLS_MODEL_INITIAL_EXEC;
1288       else if (!strcmp (arg, "local-exec"))
1289         flag_tls_default = TLS_MODEL_LOCAL_EXEC;
1290       else
1291         warning ("unknown tls-model \"%s\"", arg);
1292       break;
1293
1294     case OPT_ftracer:
1295       flag_tracer = value;
1296       break;
1297
1298     case OPT_ftrapping_math:
1299       flag_trapping_math = value;
1300       break;
1301
1302     case OPT_ftrapv:
1303       flag_trapv = value;
1304       break;
1305
1306     case OPT_funit_at_a_time:
1307       flag_unit_at_a_time = value;
1308       break;
1309
1310     case OPT_funroll_all_loops:
1311       flag_unroll_all_loops = value;
1312       break;
1313
1314     case OPT_funroll_loops:
1315       flag_unroll_loops = value;
1316       break;
1317
1318     case OPT_funsafe_math_optimizations:
1319       flag_unsafe_math_optimizations = value;
1320       break;
1321
1322     case OPT_funswitch_loops:
1323       flag_unswitch_loops = value;
1324       break;
1325
1326     case OPT_funwind_tables:
1327       flag_unwind_tables = value;
1328       break;
1329
1330     case OPT_fverbose_asm:
1331       flag_verbose_asm = value;
1332       break;
1333       
1334     case OPT_fwrapv:
1335       flag_wrapv = value;
1336       break;
1337
1338     case OPT_fwritable_strings:
1339       flag_writable_strings = value;
1340       break;
1341
1342     case OPT_fzero_initialized_in_bss:
1343       flag_zero_initialized_in_bss = value;
1344       break;
1345
1346     case OPT_g:
1347       decode_g_option (arg);
1348       break;
1349
1350     case OPT_m:
1351       set_target_switch (arg);
1352       break;
1353
1354     case OPT_o:
1355       asm_file_name = arg;
1356       break;
1357
1358     case OPT_p:
1359       profile_flag = 1;
1360       break;
1361
1362     case OPT_pedantic:
1363       pedantic = 1;
1364       break;
1365
1366     case OPT_pedantic_errors:
1367       flag_pedantic_errors = pedantic = 1;
1368       break;
1369
1370     case OPT_quiet:
1371       quiet_flag = 1;
1372       break;
1373
1374     case OPT_version:
1375       version_flag = 1;
1376       break;
1377
1378     case OPT_w:
1379       inhibit_warnings = true;
1380       break;      
1381     }
1382
1383   return 1;
1384 }
1385
1386 /* Handle --param NAME=VALUE.  */
1387 static void
1388 handle_param (const char *carg)
1389 {
1390   char *equal, *arg;
1391   int value;
1392
1393   arg = xstrdup (carg);
1394   equal = strchr (arg, '=');
1395   if (!equal)
1396     error ("%s: --param arguments should be of the form NAME=VALUE", arg);
1397   else
1398     {
1399       value = integral_argument (equal + 1);
1400       if (value == -1)
1401         error ("invalid --param value `%s'", equal + 1);
1402       else
1403         {
1404           *equal = '\0';
1405           set_param_value (arg, value);
1406         }
1407     }
1408
1409   free (arg);
1410 }
1411
1412 /* Handle -W and -Wextra.  */
1413 static void
1414 set_Wextra (int setting)
1415 {
1416   extra_warnings = setting;
1417   warn_unused_value = setting;
1418   warn_unused_parameter = (setting && maybe_warn_unused_parameter);
1419
1420   /* We save the value of warn_uninitialized, since if they put
1421      -Wuninitialized on the command line, we need to generate a
1422      warning about not using it without also specifying -O.  */
1423   if (setting == 0)
1424     warn_uninitialized = 0;
1425   else if (warn_uninitialized != 1)
1426     warn_uninitialized = 2;
1427 }
1428
1429 /* Initialize unused warning flags.  */
1430 void
1431 set_Wunused (int setting)
1432 {
1433   warn_unused_function = setting;
1434   warn_unused_label = setting;
1435   /* Unused function parameter warnings are reported when either
1436      ``-Wextra -Wunused'' or ``-Wunused-parameter'' is specified.
1437      Thus, if -Wextra has already been seen, set warn_unused_parameter;
1438      otherwise set maybe_warn_extra_parameter, which will be picked up
1439      by set_Wextra.  */
1440   maybe_warn_unused_parameter = setting;
1441   warn_unused_parameter = (setting && extra_warnings);
1442   warn_unused_variable = setting;
1443   warn_unused_value = setting;
1444 }
1445
1446 /* The following routines are useful in setting all the flags that
1447    -ffast-math and -fno-fast-math imply.  */
1448 void
1449 set_fast_math_flags (int set)
1450 {
1451   flag_trapping_math = !set;
1452   flag_unsafe_math_optimizations = set;
1453   flag_finite_math_only = set;
1454   flag_errno_math = !set;
1455   if (set)
1456     flag_signaling_nans = 0;
1457 }
1458
1459 /* Return true iff flags are set as if -ffast-math.  */
1460 bool
1461 fast_math_flags_set_p (void)
1462 {
1463   return (!flag_trapping_math
1464           && flag_unsafe_math_optimizations
1465           && flag_finite_math_only
1466           && !flag_errno_math);
1467 }