/* Handle switch SCODE with argument ARG. VALUE is true, unless no- form of an -f or -W option was given. Returns 0 if the switch was invalid, a negative number to prevent language-independent processing in toplev.c (a hack necessary for the short-term). */ int c_common_handle_option (size_t scode, const char *arg, int value) { const struct cl_option *option = &cl_options[scode]; enum opt_code code = (enum opt_code) scode; int result = 1; /* Prevent resetting the language standard to a C dialect when the driver has already determined that we're looking at assembler input. */ bool preprocessing_asm_p = (cpp_get_options (parse_in)->lang == CLK_ASM); switch (code) { default: if (cl_options[code].flags & (CL_C | CL_CXX | CL_ObjC | CL_ObjCXX)) break; #ifdef CL_Fortran if (lang_fortran && (cl_options[code].flags & (CL_Fortran))) break; #endif result = 0; break; case OPT__output_pch_: pch_file = arg; break; case OPT_A: defer_opt (code, arg); break; case OPT_C: cpp_opts->discard_comments = 0; break; case OPT_CC: cpp_opts->discard_comments = 0; cpp_opts->discard_comments_in_macro_exp = 0; break; case OPT_D: defer_opt (code, arg); break; case OPT_E: flag_preprocess_only = 1; break; case OPT_H: cpp_opts->print_include_names = 1; break; case OPT_F: TARGET_OPTF (xstrdup (arg)); break; case OPT_I: if (strcmp (arg, "-")) add_path (xstrdup (arg), BRACKET, 0, true); else { if (quote_chain_split) error ("-I- specified twice"); quote_chain_split = true; split_quote_chain (); inform ("obsolete option -I- used, please use -iquote instead"); } break; case OPT_M: case OPT_MM: /* When doing dependencies with -M or -MM, suppress normal preprocessed output, but still do -dM etc. as software depends on this. Preprocessed output does occur if -MD, -MMD or environment var dependency generation is used. */ cpp_opts->deps.style = (code == OPT_M ? DEPS_SYSTEM: DEPS_USER); flag_no_output = 1; cpp_opts->inhibit_warnings = 1; break; case OPT_MD: case OPT_MMD: cpp_opts->deps.style = (code == OPT_MD ? DEPS_SYSTEM: DEPS_USER); deps_file = arg; break; case OPT_MF: deps_seen = true; deps_file = arg; break; case OPT_MG: deps_seen = true; cpp_opts->deps.missing_files = true; break; case OPT_MP: deps_seen = true; cpp_opts->deps.phony_targets = true; break; case OPT_MQ: case OPT_MT: deps_seen = true; defer_opt (code, arg); break; case OPT_P: flag_no_line_commands = 1; break; case OPT_fworking_directory: flag_working_directory = value; break; case OPT_U: defer_opt (code, arg); break; case OPT_Wall: /* APPLE LOCAL -Wmost */ case OPT_Wmost: set_Wunused (value); set_Wformat (value); set_Wimplicit (value); warn_char_subscripts = value; warn_missing_braces = value; /* APPLE LOCAL begin -Wmost --dpatel */ if (code != OPT_Wmost) warn_parentheses = value; /* APPLE LOCAL end -Wmost --dpatel */ warn_return_type = value; warn_sequence_point = value; /* Was C only. */ if (c_dialect_cxx ()) warn_sign_compare = value; warn_switch = value; set_warn_strict_aliasing (value); warn_strict_overflow = value; warn_address = value; /* Only warn about unknown pragmas that are not in system headers. */ warn_unknown_pragmas = value; /* We save the value of warn_uninitialized, since if they put -Wuninitialized on the command line, we need to generate a warning about not using it without also specifying -O. */ if (warn_uninitialized != 1) warn_uninitialized = (value ? 2 : 0); if (!c_dialect_cxx ()) /* We set this to 2 here, but 1 in -Wmain, so -ffreestanding can turn it off only if it's not explicit. */ warn_main = value * 2; else { /* C++-specific warnings. */ warn_reorder = value; warn_nontemplate_friend = value; } cpp_opts->warn_trigraphs = value; cpp_opts->warn_comments = value; cpp_opts->warn_num_sign_change = value; cpp_opts->warn_multichar = value; /* Was C++ only. */ if (warn_pointer_sign == -1) warn_pointer_sign = 1; break; case OPT_Wcomment: case OPT_Wcomments: cpp_opts->warn_comments = value; break; case OPT_Wdeprecated: cpp_opts->warn_deprecated = value; break; case OPT_Wendif_labels: cpp_opts->warn_endif_labels = value; break; case OPT_Werror: cpp_opts->warnings_are_errors = value; global_dc->warning_as_error_requested = value; break; case OPT_Werror_implicit_function_declaration: mesg_implicit_function_declaration = 2; break; case OPT_Wformat: set_Wformat (value); break; case OPT_Wformat_: set_Wformat (atoi (arg)); break; case OPT_Wimplicit: set_Wimplicit (value); break; case OPT_Wimport: /* Silently ignore for now. */ break; case OPT_Winvalid_pch: cpp_opts->warn_invalid_pch = value; break; case OPT_Wmain: if (value) warn_main = 1; else warn_main = -1; break; case OPT_Wmissing_include_dirs: cpp_opts->warn_missing_include_dirs = value; break; case OPT_Wmultichar: cpp_opts->warn_multichar = value; break; /* APPLE LOCAL begin -Wnewline-eof */ case OPT_Wnewline_eof: cpp_opts->warn_newline_at_eof = value; break; /* APPLE LOCAL end -Wnewline-eof */ case OPT_Wnormalized_: if (!value || (arg && strcasecmp (arg, "none") == 0)) cpp_opts->warn_normalize = normalized_none; else if (!arg || strcasecmp (arg, "nfkc") == 0) cpp_opts->warn_normalize = normalized_KC; else if (strcasecmp (arg, "id") == 0) cpp_opts->warn_normalize = normalized_identifier_C; else if (strcasecmp (arg, "nfc") == 0) cpp_opts->warn_normalize = normalized_C; else error ("argument %qs to %<-Wnormalized%> not recognized", arg); break; case OPT_Wreturn_type: warn_return_type = value; break; case OPT_Wstrict_null_sentinel: warn_strict_null_sentinel = value; break; case OPT_Wsystem_headers: cpp_opts->warn_system_headers = value; break; case OPT_Wtraditional: cpp_opts->warn_traditional = value; break; case OPT_Wtrigraphs: cpp_opts->warn_trigraphs = value; break; case OPT_Wundef: cpp_opts->warn_undef = value; break; case OPT_Wunknown_pragmas: /* Set to greater than 1, so that even unknown pragmas in system headers will be warned about. */ warn_unknown_pragmas = value * 2; break; case OPT_Wunused_macros: warn_unused_macros = value; break; case OPT_Wvariadic_macros: warn_variadic_macros = value; break; case OPT_Wwrite_strings: warn_write_strings = value; break; case OPT_Weffc__: warn_ecpp = value; if (value) warn_nonvdtor = true; break; case OPT_ansi: if (!c_dialect_cxx ()) set_std_c89 (false, true); else set_std_cxx98 (true); break; case OPT_d: handle_OPT_d (arg); break; case OPT_fcond_mismatch: if (!c_dialect_cxx ()) { flag_cond_mismatch = value; break; } /* Fall through. */ case OPT_fall_virtual: case OPT_falt_external_templates: case OPT_fenum_int_equiv: case OPT_fexternal_templates: case OPT_fguiding_decls: case OPT_fhonor_std: case OPT_fhuge_objects: case OPT_flabels_ok: case OPT_fname_mangling_version_: case OPT_fnew_abi: case OPT_fnonnull_objects: case OPT_fsquangle: case OPT_fstrict_prototype: case OPT_fthis_is_variable: case OPT_fvtable_thunks: case OPT_fxref: case OPT_fvtable_gc: warning (0, "switch %qs is no longer supported", option->opt_text); break; case OPT_faccess_control: flag_access_control = value; break; case OPT_fasm: flag_no_asm = !value; break; case OPT_fbuiltin: flag_no_builtin = !value; break; case OPT_fbuiltin_: if (value) result = 0; else disable_builtin_function (arg); break; case OPT_fdirectives_only: cpp_opts->directives_only = 1; break; case OPT_fdollars_in_identifiers: cpp_opts->dollars_in_ident = value; break; case OPT_ffreestanding: value = !value; /* Fall through.... */ case OPT_fhosted: flag_hosted = value; flag_no_builtin = !value; /* warn_main will be 2 if set by -Wall, 1 if set by -Wmain */ if (!value && warn_main == 2) warn_main = 0; break; case OPT_fshort_double: flag_short_double = value; break; case OPT_fshort_enums: flag_short_enums = value; break; case OPT_fshort_wchar: flag_short_wchar = value; break; case OPT_fsigned_bitfields: flag_signed_bitfields = value; break; case OPT_fsigned_char: flag_signed_char = value; break; case OPT_funsigned_bitfields: flag_signed_bitfields = !value; break; case OPT_funsigned_char: flag_signed_char = !value; break; case OPT_fcheck_new: flag_check_new = value; break; case OPT_fconserve_space: flag_conserve_space = value; break; case OPT_fconstant_string_class_: constant_string_class_name = arg; break; case OPT_fdefault_inline: flag_default_inline = value; break; case OPT_felide_constructors: flag_elide_constructors = value; break; case OPT_fenforce_eh_specs: flag_enforce_eh_specs = value; break; case OPT_fextended_identifiers: cpp_opts->extended_identifiers = value; break; case OPT_ffor_scope: flag_new_for_scope = value; break; case OPT_fgnu_keywords: flag_no_gnu_keywords = !value; break; case OPT_fgnu_runtime: flag_next_runtime = !value; break; case OPT_fhandle_exceptions: warning (0, "-fhandle-exceptions has been renamed -fexceptions (and is now on by default)"); flag_exceptions = value; break; case OPT_fimplement_inlines: flag_implement_inlines = value; break; case OPT_fimplicit_inline_templates: flag_implicit_inline_templates = value; break; case OPT_fimplicit_templates: flag_implicit_templates = value; break; case OPT_flax_vector_conversions: flag_lax_vector_conversions = value; break; case OPT_fms_extensions: flag_ms_extensions = value; break; case OPT_fnext_runtime: flag_next_runtime = value; break; case OPT_fnil_receivers: flag_nil_receivers = value; break; case OPT_fnonansi_builtins: flag_no_nonansi_builtin = !value; break; case OPT_foperator_names: cpp_opts->operator_names = value; break; case OPT_foptional_diags: flag_optional_diags = value; break; case OPT_fpch_deps: cpp_opts->restore_pch_deps = value; break; case OPT_fpch_preprocess: flag_pch_preprocess = value; break; case OPT_fpermissive: flag_permissive = value; break; case OPT_fpreprocessed: cpp_opts->preprocessed = value; break; case OPT_freplace_objc_classes: flag_replace_objc_classes = value; break; case OPT_frepo: flag_use_repository = value; if (value) flag_implicit_templates = 0; break; case OPT_frtti: flag_rtti = value; break; case OPT_fshow_column: cpp_opts->show_column = value; break; case OPT_fstats: flag_detailed_statistics = value; break; case OPT_ftabstop_: /* It is documented that we silently ignore silly values. */ if (value >= 1 && value <= 100) cpp_opts->tabstop = value; break; case OPT_fexec_charset_: cpp_opts->narrow_charset = arg; break; case OPT_fwide_exec_charset_: cpp_opts->wide_charset = arg; break; case OPT_finput_charset_: cpp_opts->input_charset = arg; break; case OPT_ftemplate_depth_: max_tinst_depth = value; break; case OPT_fuse_cxa_atexit: flag_use_cxa_atexit = value; break; case OPT_fuse_cxa_get_exception_ptr: flag_use_cxa_get_exception_ptr = value; break; case OPT_fvisibility_inlines_hidden: visibility_options.inlines_hidden = value; break; case OPT_fweak: flag_weak = value; break; case OPT_fthreadsafe_statics: flag_threadsafe_statics = value; break; case OPT_fzero_link: flag_zero_link = value; break; case OPT_gen_decls: flag_gen_declaration = 1; break; case OPT_femit_struct_debug_baseonly: set_struct_debug_option ("base"); break; case OPT_femit_struct_debug_reduced: set_struct_debug_option ("dir:ord:sys,dir:gen:any,ind:base"); break; case OPT_femit_struct_debug_detailed_: set_struct_debug_option (arg); break; case OPT_idirafter: add_path (xstrdup (arg), AFTER, 0, true); break; case OPT_imacros: case OPT_include: defer_opt (code, arg); break; case OPT_imultilib: imultilib = arg; break; case OPT_iprefix: iprefix = arg; break; case OPT_iquote: add_path (xstrdup (arg), QUOTE, 0, true); break; case OPT_isysroot: sysroot = arg; break; case OPT_isystem: add_path (xstrdup (arg), SYSTEM, 0, true); break; case OPT_iwithprefix: add_prefixed_path (arg, SYSTEM); break; case OPT_iwithprefixbefore: add_prefixed_path (arg, BRACKET); break; case OPT_lang_asm: cpp_set_lang (parse_in, CLK_ASM); cpp_opts->dollars_in_ident = false; break; case OPT_lang_fortran: lang_fortran = true; break; case OPT_lang_objc: cpp_opts->objc = 1; break; case OPT_nostdinc: std_inc = false; break; case OPT_nostdinc__: std_cxx_inc = false; break; case OPT_o: if (!out_fname) out_fname = arg; else error ("output filename specified twice"); break; /* We need to handle the -pedantic switches here, rather than in c_common_post_options, so that a subsequent -Wno-endif-labels is not overridden. */ case OPT_pedantic_errors: cpp_opts->pedantic_errors = 1; /* Fall through. */ case OPT_pedantic: cpp_opts->pedantic = 1; cpp_opts->warn_endif_labels = 1; if (warn_pointer_sign == -1) warn_pointer_sign = 1; if (warn_overlength_strings == -1) warn_overlength_strings = 1; break; case OPT_print_objc_runtime_info: print_struct_values = 1; break; case OPT_print_pch_checksum: c_common_print_pch_checksum (stdout); exit_after_options = true; break; case OPT_remap: cpp_opts->remap = 1; break; case OPT_std_c__98: case OPT_std_gnu__98: if (!preprocessing_asm_p) set_std_cxx98 (code == OPT_std_c__98 /* ISO */); break; case OPT_std_c89: case OPT_std_iso9899_1990: case OPT_std_iso9899_199409: if (!preprocessing_asm_p) set_std_c89 (code == OPT_std_iso9899_199409 /* c94 */, true /* ISO */); break; case OPT_std_gnu89: if (!preprocessing_asm_p) set_std_c89 (false /* c94 */, false /* ISO */); break; case OPT_std_c99: case OPT_std_c9x: case OPT_std_iso9899_1999: case OPT_std_iso9899_199x: if (!preprocessing_asm_p) set_std_c99 (true /* ISO */); break; case OPT_std_gnu99: case OPT_std_gnu9x: if (!preprocessing_asm_p) set_std_c99 (false /* ISO */); break; case OPT_trigraphs: cpp_opts->trigraphs = 1; break; case OPT_traditional_cpp: cpp_opts->traditional = 1; break; case OPT_undef: flag_undef = 1; break; case OPT_w: cpp_opts->inhibit_warnings = 1; break; case OPT_v: verbose = true; break; } return result; }
static int common_handle_option (size_t scode, const char *arg, int value) { enum opt_code code = (enum opt_code) scode; switch (code) { /* APPLE LOCAL begin fat builds */ case OPT_arch: /* Ignore for now. */ break; /* APPLE LOCAL end fat builds */ case OPT__help: print_help (); exit_after_options = true; break; case OPT__param: handle_param (arg); break; case OPT__target_help: display_target_options (); exit_after_options = true; break; case OPT__version: print_version (stderr, ""); exit_after_options = true; break; case OPT_G: g_switch_value = value; g_switch_set = true; break; case OPT_O: case OPT_Os: /* Currently handled in a prescan. */ break; case OPT_W: /* For backward compatibility, -W is the same as -Wextra. */ set_Wextra (value); break; case OPT_Wextra: set_Wextra (value); break; case OPT_Wlarger_than_: larger_than_size = value; warn_larger_than = value != -1; break; case OPT_Wstrict_aliasing: case OPT_Wstrict_aliasing_: warn_strict_aliasing = value; break; case OPT_Wunused: set_Wunused (value); break; case OPT_aux_info: case OPT_aux_info_: aux_info_file_name = arg; flag_gen_aux_info = 1; break; case OPT_auxbase: aux_base_name = arg; break; /* APPLE LOCAL begin LLVM */ case OPT_mllvm: llvm_optns = arg; break; /* APPLE LOCAL end LLVM */ case OPT_auxbase_strip: { char *tmp = xstrdup (arg); strip_off_ending (tmp, strlen (tmp)); if (tmp[0]) aux_base_name = tmp; } break; case OPT_d: decode_d_option (arg); break; case OPT_dumpbase: dump_base_name = arg; break; /* APPLE LOCAL begin optimization pragmas 3124235/3420242 */ /* APPLE LOCAL end optimization pragmas 3124235/3420242 */ /* APPLE LOCAL begin falign-jumps-max-skip */ case OPT_falign_jumps_max_skip_: align_jumps_max_skip = value; break; case OPT_falign_loops_max_skip_: align_loops_max_skip = value; break; /* APPLE LOCAL end falign-jumps-max-skip */ /* APPLE LOCAL begin optimization pragmas 3124235/3420242 */ /* APPLE LOCAL end optimization pragmas 3124235/3420242 */ /* APPLE LOCAL begin predictive compilation */ case OPT_fpredictive_compilation: predictive_compilation = 0; break; case OPT_fpredictive_compilation_: { char* buf = xmalloc (strlen(arg) + 1); sprintf (buf, "%d", value); if (strcmp(buf, arg)) { error ("argument to \"-fpredictive-compilation=\" should be a valid non-negative integer instead of \"%s\"", arg); value = 0; } free(buf); predictive_compilation = value; break; } /* APPLE LOCAL end predictive compilation */ case OPT_fbranch_probabilities: flag_branch_probabilities_set = true; break; case OPT_fcall_used_: fix_register (arg, 0, 1); break; case OPT_fcall_saved_: fix_register (arg, 0, 0); break; case OPT_fdiagnostics_show_location_: if (!strcmp (arg, "once")) diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE; else if (!strcmp (arg, "every-line")) diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE; else return 0; break; case OPT_fdump_: if (!dump_switch_p (arg)) return 0; break; case OPT_ffast_math: set_fast_math_flags (value); break; case OPT_ffixed_: fix_register (arg, 1, 1); break; case OPT_finline_limit_: case OPT_finline_limit_eq: set_param_value ("max-inline-insns-single", value / 2); set_param_value ("max-inline-insns-auto", value / 2); break; case OPT_fmessage_length_: pp_set_line_maximum_length (global_dc->printer, value); break; case OPT_fpack_struct_: if (value <= 0 || (value & (value - 1)) || value > 16) error("structure alignment must be a small power of two, not %d", value); else { initial_max_fld_align = value; maximum_field_alignment = value * BITS_PER_UNIT; } break; case OPT_fpeel_loops: flag_peel_loops_set = true; break; case OPT_fprofile_arcs: profile_arc_flag_set = true; break; /* APPLE LOCAL begin add fuse-profile */ case OPT_fuse_profile: /* APPLE LOCAL end add fuse-profile */ case OPT_fprofile_use: if (!flag_branch_probabilities_set) flag_branch_probabilities = value; if (!flag_profile_values_set) flag_profile_values = value; if (!flag_unroll_loops_set) flag_unroll_loops = value; if (!flag_peel_loops_set) flag_peel_loops = value; if (!flag_tracer_set) flag_tracer = value; if (!flag_value_profile_transformations_set) flag_value_profile_transformations = value; #ifdef HAVE_prefetch if (0 && !flag_speculative_prefetching_set) flag_speculative_prefetching = value; #endif break; /* APPLE LOCAL begin add fcreate-profile */ case OPT_fcreate_profile: /* APPLE LOCAL end add fcreate-profile */ case OPT_fprofile_generate: if (!profile_arc_flag_set) profile_arc_flag = value; if (!flag_profile_values_set) flag_profile_values = value; if (!flag_value_profile_transformations_set) flag_value_profile_transformations = value; if (!flag_unroll_loops_set) flag_unroll_loops = value; #ifdef HAVE_prefetch if (0 && !flag_speculative_prefetching_set) flag_speculative_prefetching = value; #endif break; case OPT_fprofile_values: flag_profile_values_set = true; break; case OPT_fvisibility_: { if (!strcmp(arg, "default")) default_visibility = VISIBILITY_DEFAULT; else if (!strcmp(arg, "internal")) default_visibility = VISIBILITY_INTERNAL; else if (!strcmp(arg, "hidden")) default_visibility = VISIBILITY_HIDDEN; else if (!strcmp(arg, "protected")) default_visibility = VISIBILITY_PROTECTED; else error ("unrecognised visibility value \"%s\"", arg); } break; case OPT_fvpt: flag_value_profile_transformations_set = true; break; case OPT_fspeculative_prefetching: flag_speculative_prefetching_set = true; break; case OPT_frandom_seed: /* The real switch is -fno-random-seed. */ if (value) return 0; flag_random_seed = NULL; break; case OPT_frandom_seed_: flag_random_seed = arg; break; /* APPLE LOCAL begin optimization pragmas 3124235/3420242 */ /* APPLE LOCAL end optimization pragmas 3124235/3420242 */ case OPT_fsched_stalled_insns_: flag_sched_stalled_insns = value; if (flag_sched_stalled_insns == 0) flag_sched_stalled_insns = -1; break; /* APPLE LOCAL begin optimization pragmas 3124235/3420242 */ /* APPLE LOCAL end optimization pragmas 3124235/3420242 */ case OPT_fstack_limit: /* The real switch is -fno-stack-limit. */ if (value) return 0; stack_limit_rtx = NULL_RTX; break; case OPT_fstack_limit_register_: { int reg = decode_reg_name (arg); if (reg < 0) error ("unrecognized register name \"%s\"", arg); else stack_limit_rtx = gen_rtx_REG (Pmode, reg); } break; case OPT_fstack_limit_symbol_: stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (arg)); break; case OPT_ftree_vectorizer_verbose_: vect_set_verbosity_level (arg); break; case OPT_ftls_model_: if (!strcmp (arg, "global-dynamic")) flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC; else if (!strcmp (arg, "local-dynamic")) flag_tls_default = TLS_MODEL_LOCAL_DYNAMIC; else if (!strcmp (arg, "initial-exec")) flag_tls_default = TLS_MODEL_INITIAL_EXEC; else if (!strcmp (arg, "local-exec")) flag_tls_default = TLS_MODEL_LOCAL_EXEC; else warning ("unknown tls-model \"%s\"", arg); break; case OPT_ftracer: flag_tracer_set = true; break; case OPT_funroll_loops: flag_unroll_loops_set = true; break; /* APPLE LOCAL begin fwritable strings */ case OPT_fwritable_strings: flag_writable_strings = value; break; /* APPLE LOCAL end fwritable strings */ case OPT_g: set_debug_level (NO_DEBUG, DEFAULT_GDB_EXTENSIONS, arg); break; case OPT_gcoff: set_debug_level (SDB_DEBUG, false, arg); break; case OPT_gdwarf_2: set_debug_level (DWARF2_DEBUG, false, arg); break; case OPT_ggdb: set_debug_level (NO_DEBUG, 2, arg); break; case OPT_gstabs: case OPT_gstabs_: set_debug_level (DBX_DEBUG, code == OPT_gstabs_, arg); break; case OPT_gvms: set_debug_level (VMS_DEBUG, false, arg); break; case OPT_gxcoff: case OPT_gxcoff_: set_debug_level (XCOFF_DEBUG, code == OPT_gxcoff_, arg); break; case OPT_m: set_target_switch (arg); break; case OPT_o: asm_file_name = arg; break; case OPT_pedantic_errors: flag_pedantic_errors = pedantic = 1; break; default: /* If the flag was handled in a standard way, assume the lack of processing here is intentional. */ /* APPLE LOCAL optimization pragmas 3124235/3420242 */ if (cl_options[scode].flag_var || cl_options[scode].access_flag) break; abort (); } return 1; }