Mercurial > hg > CbC > CbC_gcc
comparison gcc/opts.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | 3bfb6c00c1e0 |
children | b7f97abdc517 |
comparison
equal
deleted
inserted
replaced
52:c156f1bd5cd9 | 55:77e2b8dfacca |
---|---|
40 #include "insn-attr.h" /* For INSN_SCHEDULING. */ | 40 #include "insn-attr.h" /* For INSN_SCHEDULING. */ |
41 #include "target.h" | 41 #include "target.h" |
42 #include "tree-pass.h" | 42 #include "tree-pass.h" |
43 #include "dbgcnt.h" | 43 #include "dbgcnt.h" |
44 #include "debug.h" | 44 #include "debug.h" |
45 #include "plugin.h" | |
46 #include "except.h" | |
47 #include "lto-streamer.h" | |
45 | 48 |
46 /* Value of the -G xx switch, and whether it was passed or not. */ | 49 /* Value of the -G xx switch, and whether it was passed or not. */ |
47 unsigned HOST_WIDE_INT g_switch_value; | 50 unsigned HOST_WIDE_INT g_switch_value; |
48 bool g_switch_set; | 51 bool g_switch_set; |
49 | 52 |
50 /* Same for selective scheduling. */ | 53 /* Same for selective scheduling. */ |
51 bool sel_sched_switch_set; | 54 bool sel_sched_switch_set; |
52 | 55 |
53 /* True if we should exit after parsing options. */ | 56 /* True if we should exit after parsing options. */ |
54 bool exit_after_options; | 57 bool exit_after_options; |
55 | |
56 /* Print various extra warnings. -W/-Wextra. */ | |
57 bool extra_warnings; | |
58 | 58 |
59 /* True to warn about any objects definitions whose size is larger | 59 /* True to warn about any objects definitions whose size is larger |
60 than N bytes. Also want about function definitions whose returned | 60 than N bytes. Also want about function definitions whose returned |
61 values are larger than N bytes, where N is `larger_than_size'. */ | 61 values are larger than N bytes, where N is `larger_than_size'. */ |
62 bool warn_larger_than; | 62 bool warn_larger_than; |
336 | 336 |
337 /* Global visibility options. */ | 337 /* Global visibility options. */ |
338 struct visibility_flags visibility_options; | 338 struct visibility_flags visibility_options; |
339 | 339 |
340 /* What to print when a switch has no documentation. */ | 340 /* What to print when a switch has no documentation. */ |
341 #ifdef ENABLE_CHECKING | |
342 static const char undocumented_msg[] = N_("This switch lacks documentation"); | 341 static const char undocumented_msg[] = N_("This switch lacks documentation"); |
343 #else | |
344 static const char undocumented_msg[] = ""; | |
345 #endif | |
346 | 342 |
347 /* Used for bookkeeping on whether user set these flags so | 343 /* Used for bookkeeping on whether user set these flags so |
348 -fprofile-use/-fprofile-generate does not use them. */ | 344 -fprofile-use/-fprofile-generate does not use them. */ |
349 static bool profile_arc_flag_set, flag_profile_values_set; | 345 static bool profile_arc_flag_set, flag_profile_values_set; |
350 static bool flag_unroll_loops_set, flag_tracer_set; | 346 static bool flag_unroll_loops_set, flag_tracer_set; |
366 DEF_VEC_P(const_char_p); | 362 DEF_VEC_P(const_char_p); |
367 DEF_VEC_ALLOC_P(const_char_p,heap); | 363 DEF_VEC_ALLOC_P(const_char_p,heap); |
368 | 364 |
369 static VEC(const_char_p,heap) *ignored_options; | 365 static VEC(const_char_p,heap) *ignored_options; |
370 | 366 |
367 /* Language specific warning pass for unused results. */ | |
368 bool flag_warn_unused_result = false; | |
369 | |
371 /* Input file names. */ | 370 /* Input file names. */ |
372 const char **in_fnames; | 371 const char **in_fnames; |
373 unsigned num_in_fnames; | 372 unsigned num_in_fnames; |
374 | 373 |
375 static int common_handle_option (size_t scode, const char *arg, int value, | 374 static int common_handle_option (size_t scode, const char *arg, int value, |
376 unsigned int lang_mask); | 375 unsigned int lang_mask); |
377 static void handle_param (const char *); | 376 static void handle_param (const char *); |
378 static void set_Wextra (int); | |
379 static unsigned int handle_option (const char **argv, unsigned int lang_mask); | 377 static unsigned int handle_option (const char **argv, unsigned int lang_mask); |
380 static char *write_langs (unsigned int lang_mask); | 378 static char *write_langs (unsigned int lang_mask); |
381 static void complain_wrong_lang (const char *, const struct cl_option *, | 379 static void complain_wrong_lang (const char *, const struct cl_option *, |
382 unsigned int lang_mask); | 380 unsigned int lang_mask); |
383 static void handle_options (unsigned int, const char **, unsigned int); | 381 static void handle_options (unsigned int, const char **, unsigned int); |
433 complain_wrong_lang (const char *text, const struct cl_option *option, | 431 complain_wrong_lang (const char *text, const struct cl_option *option, |
434 unsigned int lang_mask) | 432 unsigned int lang_mask) |
435 { | 433 { |
436 char *ok_langs, *bad_lang; | 434 char *ok_langs, *bad_lang; |
437 | 435 |
436 /* The LTO front end inherits all the options from the first front | |
437 end that was used. However, not all the original front end | |
438 options make sense in LTO. | |
439 | |
440 A real solution would be to filter this in collect2, but collect2 | |
441 does not have access to all the option attributes to know what to | |
442 filter. So, in lto1 we silently accept inherited flags and do | |
443 nothing about it. */ | |
444 if (lang_mask & CL_LTO) | |
445 return; | |
446 | |
438 ok_langs = write_langs (option->flags); | 447 ok_langs = write_langs (option->flags); |
439 bad_lang = write_langs (lang_mask); | 448 bad_lang = write_langs (lang_mask); |
440 | 449 |
441 /* Eventually this should become a hard error IMO. */ | 450 /* Eventually this should become a hard error IMO. */ |
442 warning (0, "command line option \"%s\" is valid for %s but not for %s", | 451 warning (0, "command line option \"%s\" is valid for %s but not for %s", |
599 goto done; | 608 goto done; |
600 } | 609 } |
601 } | 610 } |
602 | 611 |
603 if (option->flag_var) | 612 if (option->flag_var) |
604 switch (option->var_type) | 613 set_option (option, value, arg); |
605 { | |
606 case CLVC_BOOLEAN: | |
607 *(int *) option->flag_var = value; | |
608 break; | |
609 | |
610 case CLVC_EQUAL: | |
611 *(int *) option->flag_var = (value | |
612 ? option->var_value | |
613 : !option->var_value); | |
614 break; | |
615 | |
616 case CLVC_BIT_CLEAR: | |
617 case CLVC_BIT_SET: | |
618 if ((value != 0) == (option->var_type == CLVC_BIT_SET)) | |
619 *(int *) option->flag_var |= option->var_value; | |
620 else | |
621 *(int *) option->flag_var &= ~option->var_value; | |
622 if (option->flag_var == &target_flags) | |
623 target_flags_explicit |= option->var_value; | |
624 break; | |
625 | |
626 case CLVC_STRING: | |
627 *(const char **) option->flag_var = arg; | |
628 break; | |
629 } | |
630 | 614 |
631 if (option->flags & lang_mask) | 615 if (option->flags & lang_mask) |
632 if (lang_hooks.handle_option (opt_index, arg, value) == 0) | 616 { |
633 result = 0; | 617 if (lang_hooks.handle_option (opt_index, arg, value) == 0) |
618 result = 0; | |
619 else | |
620 lto_register_user_option (opt_index, arg, value, lang_mask); | |
621 } | |
634 | 622 |
635 if (result && (option->flags & CL_COMMON)) | 623 if (result && (option->flags & CL_COMMON)) |
636 if (common_handle_option (opt_index, arg, value, lang_mask) == 0) | 624 { |
637 result = 0; | 625 if (common_handle_option (opt_index, arg, value, lang_mask) == 0) |
626 result = 0; | |
627 else | |
628 lto_register_user_option (opt_index, arg, value, CL_COMMON); | |
629 } | |
638 | 630 |
639 if (result && (option->flags & CL_TARGET)) | 631 if (result && (option->flags & CL_TARGET)) |
640 if (!targetm.handle_option (opt_index, arg, value)) | 632 { |
641 result = 0; | 633 if (!targetm.handle_option (opt_index, arg, value)) |
634 result = 0; | |
635 else | |
636 lto_register_user_option (opt_index, arg, value, CL_TARGET); | |
637 } | |
642 | 638 |
643 done: | 639 done: |
644 if (dup) | 640 if (dup) |
645 free (dup); | 641 free (dup); |
646 return result; | 642 return result; |
775 options processing. */ | 771 options processing. */ |
776 void | 772 void |
777 decode_options (unsigned int argc, const char **argv) | 773 decode_options (unsigned int argc, const char **argv) |
778 { | 774 { |
779 static bool first_time_p = true; | 775 static bool first_time_p = true; |
780 static int initial_max_aliased_vops; | |
781 static int initial_avg_aliased_vops; | |
782 static int initial_min_crossjump_insns; | 776 static int initial_min_crossjump_insns; |
783 static int initial_max_fields_for_field_sensitive; | 777 static int initial_max_fields_for_field_sensitive; |
784 static int initial_loop_invariant_max_bbs_in_loop; | 778 static int initial_loop_invariant_max_bbs_in_loop; |
785 static unsigned int initial_lang_mask; | 779 static unsigned int initial_lang_mask; |
786 | 780 |
796 initial_lang_mask = lang_mask = lang_hooks.init_options (argc, argv); | 790 initial_lang_mask = lang_mask = lang_hooks.init_options (argc, argv); |
797 | 791 |
798 lang_hooks.initialize_diagnostics (global_dc); | 792 lang_hooks.initialize_diagnostics (global_dc); |
799 | 793 |
800 /* Save initial values of parameters we reset. */ | 794 /* Save initial values of parameters we reset. */ |
801 initial_max_aliased_vops = MAX_ALIASED_VOPS; | |
802 initial_avg_aliased_vops = AVG_ALIASED_VOPS; | |
803 initial_min_crossjump_insns | 795 initial_min_crossjump_insns |
804 = compiler_params[PARAM_MIN_CROSSJUMP_INSNS].value; | 796 = compiler_params[PARAM_MIN_CROSSJUMP_INSNS].value; |
805 initial_max_fields_for_field_sensitive | 797 initial_max_fields_for_field_sensitive |
806 = compiler_params[PARAM_MAX_FIELDS_FOR_FIELD_SENSITIVE].value; | 798 = compiler_params[PARAM_MAX_FIELDS_FOR_FIELD_SENSITIVE].value; |
807 initial_loop_invariant_max_bbs_in_loop | 799 initial_loop_invariant_max_bbs_in_loop |
842 optimize_size = 0; | 834 optimize_size = 0; |
843 } | 835 } |
844 } | 836 } |
845 } | 837 } |
846 } | 838 } |
847 | 839 |
848 /* Use priority coloring if cover classes is not defined for the | 840 /* Use priority coloring if cover classes is not defined for the |
849 target. */ | 841 target. */ |
850 if (targetm.ira_cover_classes == NULL) | 842 if (targetm.ira_cover_classes == NULL) |
851 flag_ira_algorithm = IRA_ALGORITHM_PRIORITY; | 843 flag_ira_algorithm = IRA_ALGORITHM_PRIORITY; |
852 | 844 |
859 #ifdef CAN_DEBUG_WITHOUT_FP | 851 #ifdef CAN_DEBUG_WITHOUT_FP |
860 flag_omit_frame_pointer = opt1; | 852 flag_omit_frame_pointer = opt1; |
861 #endif | 853 #endif |
862 flag_guess_branch_prob = opt1; | 854 flag_guess_branch_prob = opt1; |
863 flag_cprop_registers = opt1; | 855 flag_cprop_registers = opt1; |
856 flag_forward_propagate = opt1; | |
864 flag_if_conversion = opt1; | 857 flag_if_conversion = opt1; |
865 flag_if_conversion2 = opt1; | 858 flag_if_conversion2 = opt1; |
866 flag_ipa_pure_const = opt1; | 859 flag_ipa_pure_const = opt1; |
867 flag_ipa_reference = opt1; | 860 flag_ipa_reference = opt1; |
868 flag_merge_constants = opt1; | 861 flag_merge_constants = opt1; |
884 flag_inline_small_functions = opt2; | 877 flag_inline_small_functions = opt2; |
885 flag_indirect_inlining = opt2; | 878 flag_indirect_inlining = opt2; |
886 flag_thread_jumps = opt2; | 879 flag_thread_jumps = opt2; |
887 flag_crossjumping = opt2; | 880 flag_crossjumping = opt2; |
888 flag_optimize_sibling_calls = opt2; | 881 flag_optimize_sibling_calls = opt2; |
889 flag_forward_propagate = opt2; | |
890 flag_cse_follow_jumps = opt2; | 882 flag_cse_follow_jumps = opt2; |
891 flag_gcse = opt2; | 883 flag_gcse = opt2; |
892 flag_expensive_optimizations = opt2; | 884 flag_expensive_optimizations = opt2; |
893 flag_rerun_cse_after_loop = opt2; | 885 flag_rerun_cse_after_loop = opt2; |
894 flag_caller_saves = opt2; | 886 flag_caller_saves = opt2; |
895 flag_peephole2 = opt2; | 887 flag_peephole2 = opt2; |
896 #ifdef INSN_SCHEDULING | 888 #ifdef INSN_SCHEDULING |
897 flag_schedule_insns = opt2; | 889 /* Only run the pre-regalloc scheduling pass if optimizing for speed. */ |
890 flag_schedule_insns = opt2 && ! optimize_size; | |
898 flag_schedule_insns_after_reload = opt2; | 891 flag_schedule_insns_after_reload = opt2; |
899 #endif | 892 #endif |
900 flag_regmove = opt2; | 893 flag_regmove = opt2; |
901 flag_strict_aliasing = opt2; | 894 flag_strict_aliasing = opt2; |
902 flag_strict_overflow = opt2; | 895 flag_strict_overflow = opt2; |
903 flag_delete_null_pointer_checks = opt2; | |
904 flag_reorder_blocks = opt2; | 896 flag_reorder_blocks = opt2; |
905 flag_reorder_functions = opt2; | 897 flag_reorder_functions = opt2; |
906 flag_tree_vrp = opt2; | 898 flag_tree_vrp = opt2; |
907 flag_tree_builtin_call_dce = opt2; | 899 flag_tree_builtin_call_dce = opt2; |
908 flag_tree_pre = opt2; | 900 flag_tree_pre = opt2; |
909 flag_tree_switch_conversion = 1; | 901 flag_tree_switch_conversion = 1; |
910 flag_ipa_cp = opt2; | 902 flag_ipa_cp = opt2; |
911 | 903 flag_ipa_sra = opt2; |
912 /* Allow more virtual operators to increase alias precision. */ | |
913 | |
914 set_param_value ("max-aliased-vops", | |
915 (opt2) ? 500 : initial_max_aliased_vops); | |
916 | 904 |
917 /* Track fields in field-sensitive alias analysis. */ | 905 /* Track fields in field-sensitive alias analysis. */ |
918 set_param_value ("max-fields-for-field-sensitive", | 906 set_param_value ("max-fields-for-field-sensitive", |
919 (opt2) ? 100 : initial_max_fields_for_field_sensitive); | 907 (opt2) ? 100 : initial_max_fields_for_field_sensitive); |
920 | 908 |
931 flag_tree_vectorize = opt3; | 919 flag_tree_vectorize = opt3; |
932 flag_ipa_cp_clone = opt3; | 920 flag_ipa_cp_clone = opt3; |
933 if (flag_ipa_cp_clone) | 921 if (flag_ipa_cp_clone) |
934 flag_ipa_cp = 1; | 922 flag_ipa_cp = 1; |
935 | 923 |
936 /* Allow even more virtual operators. Max-aliased-vops was set above for | |
937 -O2, so don't reset it unless we are at -O3. */ | |
938 if (opt3) | |
939 set_param_value ("max-aliased-vops", 1000); | |
940 | |
941 set_param_value ("avg-aliased-vops", (opt3) ? 3 : initial_avg_aliased_vops); | |
942 | |
943 /* Just -O1/-O0 optimizations. */ | 924 /* Just -O1/-O0 optimizations. */ |
944 opt1_max = (optimize <= 1); | 925 opt1_max = (optimize <= 1); |
945 align_loops = opt1_max; | 926 align_loops = opt1_max; |
946 align_jumps = opt1_max; | 927 align_jumps = opt1_max; |
947 align_labels = opt1_max; | 928 align_labels = opt1_max; |
978 | 959 |
979 /* Some targets have ABI-specified unwind tables. */ | 960 /* Some targets have ABI-specified unwind tables. */ |
980 flag_unwind_tables = targetm.unwind_tables_default; | 961 flag_unwind_tables = targetm.unwind_tables_default; |
981 } | 962 } |
982 | 963 |
964 /* Clear any options currently held for LTO. */ | |
965 lto_clear_user_options (); | |
966 | |
983 #ifdef OPTIMIZATION_OPTIONS | 967 #ifdef OPTIMIZATION_OPTIONS |
984 /* Allow default optimizations to be specified on a per-machine basis. */ | 968 /* Allow default optimizations to be specified on a per-machine basis. */ |
985 OPTIMIZATION_OPTIONS (optimize, optimize_size); | 969 OPTIMIZATION_OPTIONS (optimize, optimize_size); |
986 #endif | 970 #endif |
987 | 971 |
988 handle_options (argc, argv, lang_mask); | 972 handle_options (argc, argv, lang_mask); |
973 | |
974 /* Make DUMP_BASE_NAME relative to the AUX_BASE_NAME directory, | |
975 typically the directory to contain the object file. */ | |
976 if (aux_base_name && ! IS_ABSOLUTE_PATH (dump_base_name)) | |
977 { | |
978 const char *aux_base; | |
979 | |
980 base_of_path (aux_base_name, &aux_base); | |
981 if (aux_base_name != aux_base) | |
982 { | |
983 int dir_len = aux_base - aux_base_name; | |
984 char *new_dump_base_name = | |
985 XNEWVEC (char, strlen(dump_base_name) + dir_len + 1); | |
986 | |
987 /* Copy directory component from AUX_BASE_NAME. */ | |
988 memcpy (new_dump_base_name, aux_base_name, dir_len); | |
989 /* Append existing DUMP_BASE_NAME. */ | |
990 strcpy (new_dump_base_name + dir_len, dump_base_name); | |
991 dump_base_name = new_dump_base_name; | |
992 } | |
993 } | |
989 | 994 |
990 /* Handle related options for unit-at-a-time, toplevel-reorder, and | 995 /* Handle related options for unit-at-a-time, toplevel-reorder, and |
991 section-anchors. */ | 996 section-anchors. */ |
992 if (!flag_unit_at_a_time) | 997 if (!flag_unit_at_a_time) |
993 { | 998 { |
1036 sections of the .o and executable files does not work (currently) | 1041 sections of the .o and executable files does not work (currently) |
1037 with exception handling. This is because there is no support for | 1042 with exception handling. This is because there is no support for |
1038 generating unwind info. If flag_exceptions is turned on we need to | 1043 generating unwind info. If flag_exceptions is turned on we need to |
1039 turn off the partitioning optimization. */ | 1044 turn off the partitioning optimization. */ |
1040 | 1045 |
1041 if (flag_exceptions && flag_reorder_blocks_and_partition) | 1046 if (flag_exceptions && flag_reorder_blocks_and_partition |
1042 { | 1047 && (USING_SJLJ_EXCEPTIONS |
1043 inform (input_location, | 1048 #ifdef TARGET_UNWIND_INFO |
1044 "-freorder-blocks-and-partition does not work with exceptions"); | 1049 || 1 |
1050 #endif | |
1051 )) | |
1052 { | |
1053 inform (input_location, | |
1054 "-freorder-blocks-and-partition does not work with exceptions on this architecture"); | |
1045 flag_reorder_blocks_and_partition = 0; | 1055 flag_reorder_blocks_and_partition = 0; |
1046 flag_reorder_blocks = 1; | 1056 flag_reorder_blocks = 1; |
1047 } | 1057 } |
1048 | 1058 |
1049 /* If user requested unwind info, then turn off the partitioning | 1059 /* If user requested unwind info, then turn off the partitioning |
1050 optimization. */ | 1060 optimization. */ |
1051 | 1061 |
1052 if (flag_unwind_tables && ! targetm.unwind_tables_default | 1062 if (flag_unwind_tables && ! targetm.unwind_tables_default |
1053 && flag_reorder_blocks_and_partition) | 1063 && flag_reorder_blocks_and_partition |
1054 { | 1064 && (USING_SJLJ_EXCEPTIONS |
1055 inform (input_location, "-freorder-blocks-and-partition does not support unwind info"); | 1065 #ifdef TARGET_UNWIND_INFO |
1066 || 1 | |
1067 #endif | |
1068 )) | |
1069 { | |
1070 inform (input_location, | |
1071 "-freorder-blocks-and-partition does not support unwind info on this architecture"); | |
1056 flag_reorder_blocks_and_partition = 0; | 1072 flag_reorder_blocks_and_partition = 0; |
1057 flag_reorder_blocks = 1; | 1073 flag_reorder_blocks = 1; |
1058 } | 1074 } |
1059 | 1075 |
1060 /* If the target requested unwind info, then turn off the partitioning | 1076 /* If the target requested unwind info, then turn off the partitioning |
1061 optimization with a different message. Likewise, if the target does not | 1077 optimization with a different message. Likewise, if the target does not |
1062 support named sections. */ | 1078 support named sections. */ |
1063 | 1079 |
1064 if (flag_reorder_blocks_and_partition | 1080 if (flag_reorder_blocks_and_partition |
1065 && (!targetm.have_named_sections | 1081 && (!targetm.have_named_sections |
1066 || (flag_unwind_tables && targetm.unwind_tables_default))) | 1082 || (flag_unwind_tables && targetm.unwind_tables_default |
1083 && (USING_SJLJ_EXCEPTIONS | |
1084 #ifdef TARGET_UNWIND_INFO | |
1085 || 1 | |
1086 #endif | |
1087 )))) | |
1067 { | 1088 { |
1068 inform (input_location, | 1089 inform (input_location, |
1069 "-freorder-blocks-and-partition does not work on this architecture"); | 1090 "-freorder-blocks-and-partition does not work on this architecture"); |
1070 flag_reorder_blocks_and_partition = 0; | 1091 flag_reorder_blocks_and_partition = 0; |
1071 flag_reorder_blocks = 1; | 1092 flag_reorder_blocks = 1; |
1097 PARAM_VALUE (PARAM_LARGE_STACK_FRAME) = 100; | 1118 PARAM_VALUE (PARAM_LARGE_STACK_FRAME) = 100; |
1098 if (!PARAM_SET_P (PARAM_STACK_FRAME_GROWTH)) | 1119 if (!PARAM_SET_P (PARAM_STACK_FRAME_GROWTH)) |
1099 PARAM_VALUE (PARAM_STACK_FRAME_GROWTH) = 40; | 1120 PARAM_VALUE (PARAM_STACK_FRAME_GROWTH) = 40; |
1100 } | 1121 } |
1101 | 1122 |
1123 if (flag_lto || flag_whopr) | |
1124 { | |
1125 #ifdef ENABLE_LTO | |
1126 flag_generate_lto = 1; | |
1127 | |
1128 /* When generating IL, do not operate in whole-program mode. | |
1129 Otherwise, symbols will be privatized too early, causing link | |
1130 errors later. */ | |
1131 flag_whole_program = 0; | |
1132 #else | |
1133 error ("LTO support has not been enabled in this configuration"); | |
1134 #endif | |
1135 } | |
1136 | |
1137 /* Reconcile -flto and -fwhopr. Set additional flags as appropriate and | |
1138 check option consistency. */ | |
1139 if (flag_lto && flag_whopr) | |
1140 error ("-flto and -fwhopr are mutually exclusive"); | |
1102 } | 1141 } |
1103 | 1142 |
1104 #define LEFT_COLUMN 27 | 1143 #define LEFT_COLUMN 27 |
1105 | 1144 |
1106 /* Output ITEM, of length ITEM_WIDTH, in the left column, | 1145 /* Output ITEM, of length ITEM_WIDTH, in the left column, |
1292 for (i = 0; (1U << i) < CL_LANG_ALL; i ++) | 1331 for (i = 0; (1U << i) < CL_LANG_ALL; i ++) |
1293 if ((1U << i) & langs) | 1332 if ((1U << i) & langs) |
1294 printf (_(" None found. Use --help=%s to show *all* the options supported by the %s front-end\n"), | 1333 printf (_(" None found. Use --help=%s to show *all* the options supported by the %s front-end\n"), |
1295 lang_names[i], lang_names[i]); | 1334 lang_names[i], lang_names[i]); |
1296 } | 1335 } |
1297 | 1336 |
1298 } | 1337 } |
1299 else if (! displayed) | 1338 else if (! displayed) |
1300 printf (_(" All options with the desired characteristics have already been displayed\n")); | 1339 printf (_(" All options with the desired characteristics have already been displayed\n")); |
1301 | 1340 |
1302 putchar ('\n'); | 1341 putchar ('\n'); |
1495 { "separate", CL_SEPARATE }, | 1534 { "separate", CL_SEPARATE }, |
1496 { "common", CL_COMMON }, | 1535 { "common", CL_COMMON }, |
1497 { NULL, 0 } | 1536 { NULL, 0 } |
1498 }; | 1537 }; |
1499 unsigned int * pflags; | 1538 unsigned int * pflags; |
1500 char * comma; | 1539 const char * comma; |
1501 unsigned int lang_flag, specific_flag; | 1540 unsigned int lang_flag, specific_flag; |
1502 unsigned int len; | 1541 unsigned int len; |
1503 unsigned int i; | 1542 unsigned int i; |
1504 | 1543 |
1505 if (* a == '^') | 1544 if (* a == '^') |
1577 print_specific_help (include_flags, exclude_flags, 0); | 1616 print_specific_help (include_flags, exclude_flags, 0); |
1578 exit_after_options = true; | 1617 exit_after_options = true; |
1579 break; | 1618 break; |
1580 } | 1619 } |
1581 | 1620 |
1621 case OPT_fversion: | |
1582 case OPT__version: | 1622 case OPT__version: |
1583 print_version (stderr, ""); | |
1584 exit_after_options = true; | 1623 exit_after_options = true; |
1585 break; | 1624 break; |
1586 | 1625 |
1587 case OPT_G: | 1626 case OPT_G: |
1588 g_switch_value = value; | 1627 g_switch_value = value; |
1592 case OPT_O: | 1631 case OPT_O: |
1593 case OPT_Os: | 1632 case OPT_Os: |
1594 /* Currently handled in a prescan. */ | 1633 /* Currently handled in a prescan. */ |
1595 break; | 1634 break; |
1596 | 1635 |
1597 case OPT_W: | |
1598 /* For backward compatibility, -W is the same as -Wextra. */ | |
1599 set_Wextra (value); | |
1600 break; | |
1601 | |
1602 case OPT_Werror_: | 1636 case OPT_Werror_: |
1603 enable_warning_as_error (arg, value, lang_mask); | 1637 enable_warning_as_error (arg, value, lang_mask); |
1604 break; | 1638 break; |
1605 | 1639 |
1606 case OPT_Wextra: | |
1607 set_Wextra (value); | |
1608 break; | |
1609 | |
1610 case OPT_Wlarger_than_: | 1640 case OPT_Wlarger_than_: |
1611 /* This form corresponds to -Wlarger-than-. | 1641 /* This form corresponds to -Wlarger-than-. |
1612 Kept for backward compatibility. | 1642 Kept for backward compatibility. |
1613 Don't use it as the first argument of warning(). */ | 1643 Don't use it as the first argument of warning(). */ |
1614 | 1644 |
1615 case OPT_Wlarger_than_eq: | 1645 case OPT_Wlarger_than_eq: |
1616 larger_than_size = value; | 1646 larger_than_size = value; |
1617 warn_larger_than = value != -1; | 1647 warn_larger_than = value != -1; |
1728 case OPT_fdump_: | 1758 case OPT_fdump_: |
1729 if (!dump_switch_p (arg)) | 1759 if (!dump_switch_p (arg)) |
1730 return 0; | 1760 return 0; |
1731 break; | 1761 break; |
1732 | 1762 |
1763 case OPT_fexcess_precision_: | |
1764 if (!strcmp (arg, "fast")) | |
1765 flag_excess_precision_cmdline = EXCESS_PRECISION_FAST; | |
1766 else if (!strcmp (arg, "standard")) | |
1767 flag_excess_precision_cmdline = EXCESS_PRECISION_STANDARD; | |
1768 else | |
1769 error ("unknown excess precision style \"%s\"", arg); | |
1770 break; | |
1771 | |
1733 case OPT_ffast_math: | 1772 case OPT_ffast_math: |
1734 set_fast_math_flags (value); | 1773 set_fast_math_flags (value); |
1735 break; | 1774 break; |
1736 | 1775 |
1737 case OPT_funsafe_math_optimizations: | 1776 case OPT_funsafe_math_optimizations: |
1772 } | 1811 } |
1773 break; | 1812 break; |
1774 | 1813 |
1775 case OPT_fpeel_loops: | 1814 case OPT_fpeel_loops: |
1776 flag_peel_loops_set = true; | 1815 flag_peel_loops_set = true; |
1816 break; | |
1817 | |
1818 case OPT_fplugin_: | |
1819 #ifdef ENABLE_PLUGIN | |
1820 add_new_plugin (arg); | |
1821 #else | |
1822 error ("Plugin support is disabled. Configure with --enable-plugin."); | |
1823 #endif | |
1824 break; | |
1825 | |
1826 case OPT_fplugin_arg_: | |
1827 #ifdef ENABLE_PLUGIN | |
1828 parse_plugin_arg_opt (arg); | |
1829 #else | |
1830 error ("Plugin support is disabled. Configure with --enable-plugin."); | |
1831 #endif | |
1777 break; | 1832 break; |
1778 | 1833 |
1779 case OPT_fprofile_arcs: | 1834 case OPT_fprofile_arcs: |
1780 profile_arc_flag_set = true; | 1835 profile_arc_flag_set = true; |
1781 break; | 1836 break; |
2020 | 2075 |
2021 case OPT_gcoff: | 2076 case OPT_gcoff: |
2022 set_debug_level (SDB_DEBUG, false, arg); | 2077 set_debug_level (SDB_DEBUG, false, arg); |
2023 break; | 2078 break; |
2024 | 2079 |
2025 case OPT_gdwarf_2: | 2080 case OPT_gdwarf_: |
2026 set_debug_level (DWARF2_DEBUG, false, arg); | 2081 if (value < 2 || value > 4) |
2082 error ("dwarf version %d is not supported", value); | |
2083 else | |
2084 dwarf_version = value; | |
2085 set_debug_level (DWARF2_DEBUG, false, ""); | |
2027 break; | 2086 break; |
2028 | 2087 |
2029 case OPT_ggdb: | 2088 case OPT_ggdb: |
2030 set_debug_level (NO_DEBUG, 2, arg); | 2089 set_debug_level (NO_DEBUG, 2, arg); |
2031 break; | 2090 break; |
2050 | 2109 |
2051 case OPT_pedantic_errors: | 2110 case OPT_pedantic_errors: |
2052 flag_pedantic_errors = pedantic = 1; | 2111 flag_pedantic_errors = pedantic = 1; |
2053 break; | 2112 break; |
2054 | 2113 |
2114 case OPT_fsee: | |
2115 case OPT_fcse_skip_blocks: | |
2055 case OPT_floop_optimize: | 2116 case OPT_floop_optimize: |
2056 case OPT_frerun_loop_opt: | 2117 case OPT_frerun_loop_opt: |
2057 case OPT_fstrength_reduce: | 2118 case OPT_fstrength_reduce: |
2058 case OPT_ftree_store_copy_prop: | 2119 case OPT_ftree_store_copy_prop: |
2059 case OPT_fforce_addr: | 2120 case OPT_fforce_addr: |
2060 case OPT_ftree_salias: | 2121 case OPT_ftree_salias: |
2061 case OPT_ftree_store_ccp: | 2122 case OPT_ftree_store_ccp: |
2062 /* These are no-ops, preserved for backward compatibility. */ | 2123 /* These are no-ops, preserved for backward compatibility. */ |
2063 break; | 2124 break; |
2064 | 2125 |
2126 case OPT_fuse_linker_plugin: | |
2127 /* No-op. Used by the driver and passed to us because it starts with f.*/ | |
2128 break; | |
2129 | |
2065 default: | 2130 default: |
2066 /* If the flag was handled in a standard way, assume the lack of | 2131 /* If the flag was handled in a standard way, assume the lack of |
2067 processing here is intentional. */ | 2132 processing here is intentional. */ |
2068 gcc_assert (cl_options[scode].flag_var); | 2133 gcc_assert (cl_options[scode].flag_var); |
2069 break; | 2134 break; |
2096 } | 2161 } |
2097 | 2162 |
2098 free (arg); | 2163 free (arg); |
2099 } | 2164 } |
2100 | 2165 |
2101 /* Handle -W and -Wextra. */ | 2166 /* Used to set the level of strict aliasing warnings, |
2102 static void | |
2103 set_Wextra (int setting) | |
2104 { | |
2105 extra_warnings = setting; | |
2106 | |
2107 /* We save the value of warn_uninitialized, since if they put | |
2108 -Wuninitialized on the command line, we need to generate a | |
2109 warning about not using it without also specifying -O. */ | |
2110 if (setting == 0) | |
2111 warn_uninitialized = 0; | |
2112 else if (warn_uninitialized != 1) | |
2113 warn_uninitialized = 2; | |
2114 } | |
2115 | |
2116 /* Used to set the level of strict aliasing warnings, | |
2117 when no level is specified (i.e., when -Wstrict-aliasing, and not | 2167 when no level is specified (i.e., when -Wstrict-aliasing, and not |
2118 -Wstrict-aliasing=level was given). | 2168 -Wstrict-aliasing=level was given). |
2119 ONOFF is assumed to take value 1 when -Wstrict-aliasing is specified, | 2169 ONOFF is assumed to take value 1 when -Wstrict-aliasing is specified, |
2120 and 0 otherwise. After calling this function, wstrict_aliasing will be | 2170 and 0 otherwise. After calling this function, wstrict_aliasing will be |
2121 set to the default value of -Wstrict_aliasing=level, currently 3. */ | 2171 set to the default value of -Wstrict_aliasing=level, currently 3. */ |
2144 flag_rounding_math = 0; | 2194 flag_rounding_math = 0; |
2145 flag_cx_limited_range = 1; | 2195 flag_cx_limited_range = 1; |
2146 } | 2196 } |
2147 } | 2197 } |
2148 | 2198 |
2149 /* When -funsafe-math-optimizations is set the following | 2199 /* When -funsafe-math-optimizations is set the following |
2150 flags are set as well. */ | 2200 flags are set as well. */ |
2151 void | 2201 void |
2152 set_unsafe_math_optimizations_flags (int set) | 2202 set_unsafe_math_optimizations_flags (int set) |
2153 { | 2203 { |
2154 flag_trapping_math = !set; | 2204 flag_trapping_math = !set; |
2155 flag_signed_zeros = !set; | 2205 flag_signed_zeros = !set; |
2220 | 2270 |
2221 /* A debug flag without a level defaults to level 2. */ | 2271 /* A debug flag without a level defaults to level 2. */ |
2222 if (*arg == '\0') | 2272 if (*arg == '\0') |
2223 { | 2273 { |
2224 if (!debug_info_level) | 2274 if (!debug_info_level) |
2225 debug_info_level = 2; | 2275 debug_info_level = DINFO_LEVEL_NORMAL; |
2226 } | 2276 } |
2227 else | 2277 else |
2228 { | 2278 { |
2229 debug_info_level = integral_argument (arg); | 2279 int argval = integral_argument (arg); |
2230 if (debug_info_level == (unsigned int) -1) | 2280 if (argval == -1) |
2231 error ("unrecognised debug output level \"%s\"", arg); | 2281 error ("unrecognised debug output level \"%s\"", arg); |
2232 else if (debug_info_level > 3) | 2282 else if (argval > 3) |
2233 error ("debug output level %s is too high", arg); | 2283 error ("debug output level %s is too high", arg); |
2284 else | |
2285 debug_info_level = (enum debug_info_level) argval; | |
2234 } | 2286 } |
2235 } | 2287 } |
2236 | 2288 |
2237 /* Return 1 if OPTION is enabled, 0 if it is disabled, or -1 if it isn't | 2289 /* Return 1 if OPTION is enabled, 0 if it is disabled, or -1 if it isn't |
2238 a simple on-off switch. */ | 2290 a simple on-off switch. */ |
2295 break; | 2347 break; |
2296 } | 2348 } |
2297 return true; | 2349 return true; |
2298 } | 2350 } |
2299 | 2351 |
2352 /* Set *OPTION according to VALUE and ARG. */ | |
2353 | |
2354 void | |
2355 set_option (const struct cl_option *option, int value, const char *arg) | |
2356 { | |
2357 if (!option->flag_var) | |
2358 return; | |
2359 | |
2360 switch (option->var_type) | |
2361 { | |
2362 case CLVC_BOOLEAN: | |
2363 *(int *) option->flag_var = value; | |
2364 break; | |
2365 | |
2366 case CLVC_EQUAL: | |
2367 *(int *) option->flag_var = (value | |
2368 ? option->var_value | |
2369 : !option->var_value); | |
2370 break; | |
2371 | |
2372 case CLVC_BIT_CLEAR: | |
2373 case CLVC_BIT_SET: | |
2374 if ((value != 0) == (option->var_type == CLVC_BIT_SET)) | |
2375 *(int *) option->flag_var |= option->var_value; | |
2376 else | |
2377 *(int *) option->flag_var &= ~option->var_value; | |
2378 if (option->flag_var == &target_flags) | |
2379 target_flags_explicit |= option->var_value; | |
2380 break; | |
2381 | |
2382 case CLVC_STRING: | |
2383 *(const char **) option->flag_var = arg; | |
2384 break; | |
2385 } | |
2386 } | |
2387 | |
2300 /* Enable a warning option as an error. This is used by -Werror= and | 2388 /* Enable a warning option as an error. This is used by -Werror= and |
2301 also by legacy Werror-implicit-function-declaration. */ | 2389 also by legacy Werror-implicit-function-declaration. */ |
2302 | 2390 |
2303 void | 2391 void |
2304 enable_warning_as_error (const char *arg, int value, unsigned int lang_mask) | 2392 enable_warning_as_error (const char *arg, int value, unsigned int lang_mask) |
2314 { | 2402 { |
2315 error ("-Werror=%s: No option -%s", arg, new_option); | 2403 error ("-Werror=%s: No option -%s", arg, new_option); |
2316 } | 2404 } |
2317 else | 2405 else |
2318 { | 2406 { |
2319 int kind = value ? DK_ERROR : DK_WARNING; | 2407 diagnostic_t kind = value ? DK_ERROR : DK_WARNING; |
2320 diagnostic_classify_diagnostic (global_dc, option_index, kind); | 2408 diagnostic_classify_diagnostic (global_dc, option_index, kind); |
2321 | 2409 |
2322 /* -Werror=foo implies -Wfoo. */ | 2410 /* -Werror=foo implies -Wfoo. */ |
2323 if (cl_options[option_index].var_type == CLVC_BOOLEAN | 2411 if (cl_options[option_index].var_type == CLVC_BOOLEAN |
2324 && cl_options[option_index].flag_var | 2412 && cl_options[option_index].flag_var |
2325 && kind == DK_ERROR) | 2413 && kind == DK_ERROR) |
2326 *(int *) cl_options[option_index].flag_var = 1; | 2414 *(int *) cl_options[option_index].flag_var = 1; |