This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Add 2 more features to generic option handling


Java, and at least my intended handling of -O from toplev.c, needs the
ability to have an optional joined argument.  At present this is kludged
in Java, so I've added the generic ability of a joined argument being
optional and removed the kludge.

Also, many switches take an integral value that is >= 0.  So far the
conversion of this argument to an integer has been done in an ad-hoc
way, or using read_integral_parameter.  It's nice to have the generic
code handle this case, particularly since no extra arguments are needed
to the front-end hook: we use the value parameter which is an "int".

Most of this patch is renaming "on" to "value" in c-opts.c; this was
the first front end that had the new option handling; I was able to
anticipate this change with the others by naming it "value" from the
start.

Bootstrapped x86 NetBSD C, ObjC, C++, F77, Java and Treelang without
regressions.

Neil.

	* c-opts.c (c_common_handle_option): s/on/value/.
	(OPT_fabi_version_, OPT_ftabstop_, OPT_ftemplate_depth_): Use value
	directly rather than converting the argument.
	* c.opt: Update docs.  Use UInteger where appropriate.
	* common.opt: Use UInteger where appropriate.
	* opts.c (integral_argument): New.
	(handle_argument): Handle integral arguments, and optional
	joined arguments.
	(common_handle_option): Update.
	* opts.h (CL_MISSING_OK, CL_UINTEGER): New.
	* opts.sh: Handle JoinedOrMissing and UInteger flags.
java:
	* lang.c (java_handle_option): Special-casing of optional
	joined arguments no longer needed.
	* lang.opt: Update switches that take optional argument.

Index: c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.58
diff -u -p -b -r1.58 c-opts.c
--- c-opts.c	15 Jun 2003 14:56:24 -0000	1.58
+++ c-opts.c	16 Jun 2003 05:39:20 -0000
@@ -244,7 +244,7 @@ c_common_init_options (lang)
    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 on)
+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;
@@ -265,7 +265,7 @@ c_common_handle_option (size_t scode, co
   lang_mask = lang_flags[(c_language << 1) + flag_objc];
   if (!(option->flags & lang_mask))
     {
-      complain_wrong_lang (code, on);
+      complain_wrong_lang (code, value);
       return 1;
     }
 
@@ -372,95 +372,95 @@ c_common_handle_option (size_t scode, co
       break;
 
     case OPT_Wabi:
-      warn_abi = on;
+      warn_abi = value;
       break;
 
     case OPT_Wall:
-      set_Wunused (on);
-      set_Wformat (on);
-      set_Wimplicit (on);
-      warn_char_subscripts = on;
-      warn_missing_braces = on;
-      warn_parentheses = on;
-      warn_return_type = on;
-      warn_sequence_point = on;	/* Was C only.  */
+      set_Wunused (value);
+      set_Wformat (value);
+      set_Wimplicit (value);
+      warn_char_subscripts = value;
+      warn_missing_braces = value;
+      warn_parentheses = value;
+      warn_return_type = value;
+      warn_sequence_point = value;	/* Was C only.  */
       if (c_language == clk_cplusplus)
-	warn_sign_compare = on;
-      warn_switch = on;
-      warn_strict_aliasing = on;
+	warn_sign_compare = value;
+      warn_switch = value;
+      warn_strict_aliasing = value;
       
       /* Only warn about unknown pragmas that are not in system
 	 headers.  */                                        
-      warn_unknown_pragmas = on;
+      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 = (on ? 2 : 0);
+	warn_uninitialized = (value ? 2 : 0);
 
       if (c_language == clk_c)
 	/* We set this to 2 here, but 1 in -Wmain, so -ffreestanding
 	   can turn it off only if it's not explicit.  */
-	warn_main = on * 2;
+	warn_main = value * 2;
       else
 	{
 	  /* C++-specific warnings.  */
-	  warn_nonvdtor = on;
-	  warn_reorder = on;
-	  warn_nontemplate_friend = on;
+	  warn_nonvdtor = value;
+	  warn_reorder = value;
+	  warn_nontemplate_friend = value;
 	}
 
-      cpp_opts->warn_trigraphs = on;
-      cpp_opts->warn_comments = on;
-      cpp_opts->warn_num_sign_change = on;
-      cpp_opts->warn_multichar = on;	/* Was C++ only.  */
+      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.  */
       break;
 
     case OPT_Wbad_function_cast:
-      warn_bad_function_cast = on;
+      warn_bad_function_cast = value;
       break;
 
     case OPT_Wcast_qual:
-      warn_cast_qual = on;
+      warn_cast_qual = value;
       break;
 
     case OPT_Wchar_subscripts:
-      warn_char_subscripts = on;
+      warn_char_subscripts = value;
       break;
 
     case OPT_Wcomment:
     case OPT_Wcomments:
-      cpp_opts->warn_comments = on;
+      cpp_opts->warn_comments = value;
       break;
 
     case OPT_Wconversion:
-      warn_conversion = on;
+      warn_conversion = value;
       break;
 
     case OPT_Wctor_dtor_privacy:
-      warn_ctor_dtor_privacy = on;
+      warn_ctor_dtor_privacy = value;
       break;
 
     case OPT_Wdeprecated:
-      warn_deprecated = on;
-      cpp_opts->warn_deprecated = on;
+      warn_deprecated = value;
+      cpp_opts->warn_deprecated = value;
       break;
 
     case OPT_Wdiv_by_zero:
-      warn_div_by_zero = on;
+      warn_div_by_zero = value;
       break;
 
     case OPT_Weffc__:
-      warn_ecpp = on;
+      warn_ecpp = value;
       break;
 
     case OPT_Wendif_labels:
-      cpp_opts->warn_endif_labels = on;
+      cpp_opts->warn_endif_labels = value;
       break;
 
     case OPT_Werror:
-      cpp_opts->warnings_are_errors = on;
+      cpp_opts->warnings_are_errors = value;
       break;
 
     case OPT_Werror_implicit_function_declaration:
@@ -468,11 +468,11 @@ c_common_handle_option (size_t scode, co
       break;
 
     case OPT_Wfloat_equal:
-      warn_float_equal = on;
+      warn_float_equal = value;
       break;
 
     case OPT_Wformat:
-      set_Wformat (on);
+      set_Wformat (value);
       break;
 
     case OPT_Wformat_:
@@ -480,192 +480,192 @@ c_common_handle_option (size_t scode, co
       break;
 
     case OPT_Wformat_extra_args:
-      warn_format_extra_args = on;
+      warn_format_extra_args = value;
       break;
 
     case OPT_Wformat_nonliteral:
-      warn_format_nonliteral = on;
+      warn_format_nonliteral = value;
       break;
 
     case OPT_Wformat_security:
-      warn_format_security = on;
+      warn_format_security = value;
       break;
 
     case OPT_Wformat_y2k:
-      warn_format_y2k = on;
+      warn_format_y2k = value;
       break;
 
     case OPT_Wformat_zero_length:
-      warn_format_zero_length = on;
+      warn_format_zero_length = value;
       break;
 
     case OPT_Wimplicit:
-      set_Wimplicit (on);
+      set_Wimplicit (value);
       break;
 
     case OPT_Wimplicit_function_declaration:
-      mesg_implicit_function_declaration = on;
+      mesg_implicit_function_declaration = value;
       break;
 
     case OPT_Wimplicit_int:
-      warn_implicit_int = on;
+      warn_implicit_int = value;
       break;
 
     case OPT_Wimport:
-      cpp_opts->warn_import = on;
+      cpp_opts->warn_import = value;
       break;
 
     case OPT_Winvalid_offsetof:
-      warn_invalid_offsetof = on;
+      warn_invalid_offsetof = value;
       break;
 
     case OPT_Winvalid_pch:
-      cpp_opts->warn_invalid_pch = on;
+      cpp_opts->warn_invalid_pch = value;
       break;
 
     case OPT_Wlong_long:
-      warn_long_long = on;
+      warn_long_long = value;
       break;
 
     case OPT_Wmain:
-      if (on)
+      if (value)
 	warn_main = 1;
       else
 	warn_main = -1;
       break;
 
     case OPT_Wmissing_braces:
-      warn_missing_braces = on;
+      warn_missing_braces = value;
       break;
 
     case OPT_Wmissing_declarations:
-      warn_missing_declarations = on;
+      warn_missing_declarations = value;
       break;
 
     case OPT_Wmissing_format_attribute:
-      warn_missing_format_attribute = on;
+      warn_missing_format_attribute = value;
       break;
 
     case OPT_Wmissing_prototypes:
-      warn_missing_prototypes = on;
+      warn_missing_prototypes = value;
       break;
 
     case OPT_Wmultichar:
-      cpp_opts->warn_multichar = on;
+      cpp_opts->warn_multichar = value;
       break;
 
     case OPT_Wnested_externs:
-      warn_nested_externs = on;
+      warn_nested_externs = value;
       break;
 
     case OPT_Wnon_template_friend:
-      warn_nontemplate_friend = on;
+      warn_nontemplate_friend = value;
       break;
 
     case OPT_Wnon_virtual_dtor:
-      warn_nonvdtor = on;
+      warn_nonvdtor = value;
       break;
 
     case OPT_Wnonnull:
-      warn_nonnull = on;
+      warn_nonnull = value;
       break;
 
     case OPT_Wold_style_cast:
-      warn_old_style_cast = on;
+      warn_old_style_cast = value;
       break;
 
     case OPT_Woverloaded_virtual:
-      warn_overloaded_virtual = on;
+      warn_overloaded_virtual = value;
       break;
 
     case OPT_Wparentheses:
-      warn_parentheses = on;
+      warn_parentheses = value;
       break;
 
     case OPT_Wpmf_conversions:
-      warn_pmf2ptr = on;
+      warn_pmf2ptr = value;
       break;
 
     case OPT_Wpointer_arith:
-      warn_pointer_arith = on;
+      warn_pointer_arith = value;
       break;
 
     case OPT_Wprotocol:
-      warn_protocol = on;
+      warn_protocol = value;
       break;
 
     case OPT_Wselector:
-      warn_selector = on;
+      warn_selector = value;
       break;
 
     case OPT_Wredundant_decls:
-      warn_redundant_decls = on;
+      warn_redundant_decls = value;
       break;
 
     case OPT_Wreorder:
-      warn_reorder = on;
+      warn_reorder = value;
       break;
 
     case OPT_Wreturn_type:
-      warn_return_type = on;
+      warn_return_type = value;
       break;
 
     case OPT_Wsequence_point:
-      warn_sequence_point = on;
+      warn_sequence_point = value;
       break;
 
     case OPT_Wsign_compare:
-      warn_sign_compare = on;
+      warn_sign_compare = value;
       break;
 
     case OPT_Wsign_promo:
-      warn_sign_promo = on;
+      warn_sign_promo = value;
       break;
 
     case OPT_Wstrict_prototypes:
-      warn_strict_prototypes = on;
+      warn_strict_prototypes = value;
       break;
 
     case OPT_Wsynth:
-      warn_synth = on;
+      warn_synth = value;
       break;
 
     case OPT_Wsystem_headers:
-      cpp_opts->warn_system_headers = on;
+      cpp_opts->warn_system_headers = value;
       break;
 
     case OPT_Wtraditional:
-      warn_traditional = on;
-      cpp_opts->warn_traditional = on;
+      warn_traditional = value;
+      cpp_opts->warn_traditional = value;
       break;
 
     case OPT_Wtrigraphs:
-      cpp_opts->warn_trigraphs = on;
+      cpp_opts->warn_trigraphs = value;
       break;
 
     case OPT_Wundeclared_selector:
-      warn_undeclared_selector = on;
+      warn_undeclared_selector = value;
       break;
 
     case OPT_Wundef:
-      cpp_opts->warn_undef = on;
+      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 = on * 2;
+      warn_unknown_pragmas = value * 2;
       break;
 
     case OPT_Wunused_macros:
-      warn_unused_macros = on;
+      warn_unused_macros = value;
       break;
 
     case OPT_Wwrite_strings:
       if (c_language == clk_c)
-	flag_const_strings = on;
+	flag_const_strings = value;
       else
-	warn_write_strings = on;
+	warn_write_strings = value;
       break;
       
     case OPT_ansi:
@@ -682,7 +682,7 @@ c_common_handle_option (size_t scode, co
     case OPT_fcond_mismatch:
       if (c_language == clk_c)
 	{
-	  flag_cond_mismatch = on;
+	  flag_cond_mismatch = value;
 	  break;
 	}
       /* Fall through.  */
@@ -705,38 +705,38 @@ c_common_handle_option (size_t scode, co
       break;
 
     case OPT_fabi_version_:
-      flag_abi_version = read_integral_parameter (arg, option->opt_text, 1);
+      flag_abi_version = value;
       break;
 
     case OPT_faccess_control:
-      flag_access_control = on;
+      flag_access_control = value;
       break;
 
     case OPT_falt_external_templates:
-      flag_alt_external_templates = on;
-      if (on)
+      flag_alt_external_templates = value;
+      if (value)
 	flag_external_templates = true;
     cp_deprecated:
       warning ("switch \"%s\" is deprecated, please see documentation for details", option->opt_text);
       break;
 
     case OPT_fasm:
-      flag_no_asm = !on;
+      flag_no_asm = !value;
       break;
 
     case OPT_fbuiltin:
-      flag_no_builtin = !on;
+      flag_no_builtin = !value;
       break;
 
     case OPT_fbuiltin_:
-      if (on)
+      if (value)
 	result = 0;
       else
 	disable_builtin_function (arg);
       break;
 
     case OPT_fdollars_in_identifiers:
-      cpp_opts->dollars_in_ident = on;
+      cpp_opts->dollars_in_ident = value;
       break;
 
     case OPT_fdump_:
@@ -745,56 +745,56 @@ c_common_handle_option (size_t scode, co
       break;
 
     case OPT_ffreestanding:
-      on = !on;
+      value = !value;
       /* Fall through...  */
     case OPT_fhosted:
-      flag_hosted = on;
-      flag_no_builtin = !on;
+      flag_hosted = value;
+      flag_no_builtin = !value;
       /* warn_main will be 2 if set by -Wall, 1 if set by -Wmain */
-      if (!on && warn_main == 2)
+      if (!value && warn_main == 2)
 	warn_main = 0;
       break;
 
     case OPT_fshort_double:
-      flag_short_double = on;
+      flag_short_double = value;
       break;
 
     case OPT_fshort_enums:
-      flag_short_enums = on;
+      flag_short_enums = value;
       break;
 
     case OPT_fshort_wchar:
-      flag_short_wchar = on;
+      flag_short_wchar = value;
       break;
 
     case OPT_fsigned_bitfields:
-      flag_signed_bitfields = on;
+      flag_signed_bitfields = value;
       explicit_flag_signed_bitfields = 1;
       break;
 
     case OPT_fsigned_char:
-      flag_signed_char = on;
+      flag_signed_char = value;
       break;
 
     case OPT_funsigned_bitfields:
-      flag_signed_bitfields = !on;
+      flag_signed_bitfields = !value;
       explicit_flag_signed_bitfields = 1;
       break;
 
     case OPT_funsigned_char:
-      flag_signed_char = !on;
+      flag_signed_char = !value;
       break;
 
     case OPT_fcheck_new:
-      flag_check_new = on;
+      flag_check_new = value;
       break;
 
     case OPT_fconserve_space:
-      flag_conserve_space = on;
+      flag_conserve_space = value;
       break;
 
     case OPT_fconst_strings:
-      flag_const_strings = on;
+      flag_const_strings = value;
       break;
 
     case OPT_fconstant_string_class_:
@@ -802,19 +802,19 @@ c_common_handle_option (size_t scode, co
       break;
 
     case OPT_fdefault_inline:
-      flag_default_inline = on;
+      flag_default_inline = value;
       break;
 
     case OPT_felide_constructors:
-      flag_elide_constructors = on;
+      flag_elide_constructors = value;
       break;
 
     case OPT_fenforce_eh_specs:
-      flag_enforce_eh_specs = on;
+      flag_enforce_eh_specs = value;
       break;
 
     case OPT_fexternal_templates:
-      flag_external_templates = on;
+      flag_external_templates = value;
       goto cp_deprecated;
 
     case OPT_ffixed_form:
@@ -825,108 +825,104 @@ c_common_handle_option (size_t scode, co
       break;
 
     case OPT_ffor_scope:
-      flag_new_for_scope = on;
+      flag_new_for_scope = value;
       break;
 
     case OPT_fgnu_keywords:
-      flag_no_gnu_keywords = !on;
+      flag_no_gnu_keywords = !value;
       break;
 
     case OPT_fgnu_runtime:
-      flag_next_runtime = !on;
+      flag_next_runtime = !value;
       break;
 
     case OPT_fhandle_exceptions:
       warning ("-fhandle-exceptions has been renamed -fexceptions (and is now on by default)");
-      flag_exceptions = on;
+      flag_exceptions = value;
       break;
 
     case OPT_fimplement_inlines:
-      flag_implement_inlines = on;
+      flag_implement_inlines = value;
       break;
 
     case OPT_fimplicit_inline_templates:
-      flag_implicit_inline_templates = on;
+      flag_implicit_inline_templates = value;
       break;
 
     case OPT_fimplicit_templates:
-      flag_implicit_templates = on;
+      flag_implicit_templates = value;
       break;
 
     case OPT_fms_extensions:
-      flag_ms_extensions = on;
+      flag_ms_extensions = value;
       break;
 
     case OPT_fnext_runtime:
-      flag_next_runtime = on;
+      flag_next_runtime = value;
       break;
 
     case OPT_fnonansi_builtins:
-      flag_no_nonansi_builtin = !on;
+      flag_no_nonansi_builtin = !value;
       break;
 
     case OPT_foperator_names:
-      cpp_opts->operator_names = on;
+      cpp_opts->operator_names = value;
       break;
 
     case OPT_foptional_diags:
-      flag_optional_diags = on;
+      flag_optional_diags = value;
       break;
 
     case OPT_fpch_deps:
-      cpp_opts->restore_pch_deps = on;
+      cpp_opts->restore_pch_deps = value;
       break;
 
     case OPT_fpermissive:
-      flag_permissive = on;
+      flag_permissive = value;
       break;
 
     case OPT_fpreprocessed:
-      cpp_opts->preprocessed = on;
+      cpp_opts->preprocessed = value;
       break;
 
     case OPT_frepo:
-      flag_use_repository = on;
-      if (on)
+      flag_use_repository = value;
+      if (value)
 	flag_implicit_templates = 0;
       break;
 
     case OPT_frtti:
-      flag_rtti = on;
+      flag_rtti = value;
       break;
 
     case OPT_fshow_column:
-      cpp_opts->show_column = on;
+      cpp_opts->show_column = value;
       break;
 
     case OPT_fstats:
-      flag_detailed_statistics = on;
+      flag_detailed_statistics = value;
       break;
 
     case OPT_ftabstop_:
       /* It is documented that we silently ignore silly values.  */
-	{
-	  char *endptr;
-	  long tabstop = strtol (arg, &endptr, 10);
-	  if (*endptr == '\0' && tabstop >= 1 && tabstop <= 100)
-	    cpp_opts->tabstop = tabstop;
-	}
+      if (value >= 1 && value <= 100)
+	cpp_opts->tabstop = value;
       break;
 
     case OPT_ftemplate_depth_:
-      max_tinst_depth = read_integral_parameter (arg, option->opt_text, 0);
+      max_tinst_depth = value;
       break;
 
     case OPT_fvtable_gc:
-      flag_vtable_gc = on;
+      flag_vtable_gc = value;
       break;
 
     case OPT_fuse_cxa_atexit:
-      flag_use_cxa_atexit = on;
+      flag_use_cxa_atexit = value;
       break;
 
     case OPT_fweak:
-      flag_weak = on;
+      flag_weak = value;
       break;
 
     case OPT_gen_decls:
Index: c.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c.opt,v
retrieving revision 1.4
diff -u -p -b -r1.4 c.opt
--- c.opt	15 Jun 2003 14:56:24 -0000	1.4
+++ c.opt	16 Jun 2003 05:39:20 -0000
@@ -32,7 +32,11 @@
 ; compiler recognize the switch, as declared by "Language" entries.
 ; If the switch takes an argument, then you should also specify
 ; "Joined" and/or "Separate" to indicate where the argument can
-; appear.
+; appear.  If a Joined argument can legitimately be omitted, specify
+; "JoinedOrMissing" instead of "Joined".  If the argument to a switch
+; is a non-negative integer, you can specify "UInteger" and the switch
+; decoder will convert the argument for you, or complain to the user
+; if the argument is invalid.
 
 ; Comments can appear on their own line anwhere in the file, preceded
 ; by a semicolon.  Whitespace is permitted before the semicolon.
@@ -311,7 +315,7 @@ d
 C ObjC C++ ObjC++ Joined
 
 fabi-version=
-C++ ObjC++ Joined
+C++ ObjC++ Joined UInteger
 
 faccess-control
 C++ ObjC++
@@ -479,10 +483,10 @@ fstrict-prototype
 C++ ObjC++
 
 ftabstop=
-C ObjC C++ ObjC++ Joined RejectNegative
+C ObjC C++ ObjC++ Joined RejectNegative UInteger
 
 ftemplate-depth-
-C++ ObjC++ Joined
+C++ ObjC++ Joined RejectNegative UInteger 
 
 fthis-is-variable
 C++ ObjC++
Index: common.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/common.opt,v
retrieving revision 1.2
diff -u -p -b -r1.2 common.opt
--- common.opt	15 Jun 2003 08:29:58 -0000	1.2
+++ common.opt	16 Jun 2003 05:39:20 -0000
@@ -51,7 +51,7 @@ Common
 Common
 
 G
-Common Joined Separate
+Common Joined Separate UInteger
 
 aux-info
 Common Separate
Index: opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.c,v
retrieving revision 1.6
diff -u -p -b -r1.6 opts.c
--- opts.c	15 Jun 2003 08:29:59 -0000	1.6
+++ opts.c	16 Jun 2003 05:39:20 -0000
@@ -130,6 +130,22 @@ find_opt (const char *input, int lang_ma
   return result;
 }
 
+/* If ARG is a postive integer made up solely of digits, return its
+   value, otherwise return -1.  */
+static int
+integral_argument (const char *arg)
+{
+  const char *p = arg;
+
+  while (*p && ISDIGIT (*p))
+    p++;
+
+  if (*p == '\0')
+    return atoi (arg);
+
+  return -1;
+}
+
 /* Handle the switch beginning at ARGV, with ARGC remaining.  */
 int
 handle_option (int argc ATTRIBUTE_UNUSED, char **argv, int lang_mask)
@@ -137,7 +153,7 @@ handle_option (int argc ATTRIBUTE_UNUSED
   size_t opt_index;
   const char *opt, *arg = 0;
   char *dup = 0;
-  bool on = true;
+  int value = 1;
   int result = 0, temp;
   const struct cl_option *option;
 
@@ -149,7 +165,7 @@ handle_option (int argc ATTRIBUTE_UNUSED
       opt_index = cl_options_count;
       arg = opt;
       main_input_filename = opt;
-      result = (*lang_hooks.handle_option) (opt_index, arg, on);
+      result = (*lang_hooks.handle_option) (opt_index, arg, value);
     }
   else
     {
@@ -164,7 +180,7 @@ handle_option (int argc ATTRIBUTE_UNUSED
 	  dup[1] = opt[1];
 	  memcpy (dup + 2, opt + 5, len - 2 + 1);
 	  opt = dup;
-	  on = false;
+	  value = 0;
 	}
 
       opt_index = find_opt (opt + 1, lang_mask | CL_COMMON);
@@ -174,48 +190,62 @@ handle_option (int argc ATTRIBUTE_UNUSED
       option = &cl_options[opt_index];
 
       /* Reject negative form of switches that don't take negatives.  */
-      if (!on && (option->flags & CL_REJECT_NEGATIVE))
+      if (!value && (option->flags & CL_REJECT_NEGATIVE))
 	goto done;
 
       /* We've recognized this switch.  */
       result = 1;
 
       /* Sort out any argument the switch takes.  */
-      if (option->flags & (CL_JOINED | CL_SEPARATE))
-	{
 	  if (option->flags & CL_JOINED)
 	    {
 	      /* Have arg point to the original switch.  This is because
 		 some code, such as disable_builtin_function, expects its
 		 argument to be persistent until the program exits.  */
 	      arg = argv[0] + cl_options[opt_index].opt_len + 1;
-	      if (!on)
+	  if (!value)
 		arg += strlen ("no-");
-	    }
 
-	  /* If we don't have an argument, and CL_SEPARATE, try the next
-	     argument in the vector.  */
-	  if (!arg || (*arg == '\0' && option->flags & CL_SEPARATE))
+	  if (*arg == '\0' && !(option->flags & CL_MISSING_OK))
+	    {
+	      if (option->flags & CL_SEPARATE)
 	    {
 	      arg = argv[1];
 	      result = 2;
 	    }
-
-	  /* Canonicalize missing arguments as NULL for the handler.  */
-	  if (*arg == '\0')
+	      else
+		/* Missing argument.  */
 	    arg = NULL;
 	}
+	}
+      else if (option->flags & CL_SEPARATE)
+	{
+	  arg = argv[1];
+	  result = 2;
+	}
+
+      /* If the switch takes an integer, convert it.  */
+      if (arg && (option->flags & CL_UINTEGER))
+	{
+	  value = integral_argument (arg);
+	  if (value == -1)
+	    {
+	      error ("argument to \"-%s\" should be a non-negative integer",
+		     option->opt_text);
+	      goto done;
+	    }
+	}
 
       if (option->flags & lang_mask)
 	{
-	  temp = (*lang_hooks.handle_option) (opt_index, arg, on);
+	  temp = (*lang_hooks.handle_option) (opt_index, arg, value);
 	  if (temp <= 0)
 	    result = temp;
 	}
 
       if (result > 0 && (option->flags & CL_COMMON))
 	{
-	  if (common_handle_option (opt_index, arg, on) == 0)
+	  if (common_handle_option (opt_index, arg, value) == 0)
 	    result = 0;
 	}
     }
@@ -262,9 +292,7 @@ common_handle_option (size_t scode, cons
       break;
 
     case OPT_G:
-      g_switch_value = read_integral_parameter (arg, 0, -1);
-      if (g_switch_value == (unsigned HOST_WIDE_INT) -1)
-	return 0;
+      g_switch_value = value;
       g_switch_set = true;
       break;
 
Index: opts.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.h,v
retrieving revision 1.4
diff -u -p -b -r1.4 opts.h
--- opts.h	15 Jun 2003 14:56:24 -0000	1.4
+++ opts.h	16 Jun 2003 05:39:20 -0000
@@ -36,6 +36,8 @@ extern const unsigned int cl_options_cou
 #define CL_JOINED		(1 << 24) /* If takes joined argument.  */
 #define CL_SEPARATE		(1 << 25) /* If takes a separate argument.  */
 #define CL_REJECT_NEGATIVE	(1 << 26) /* Reject no- form.  */
-#define CL_COMMON		(1 << 27) /* Language-independent.  */
+#define CL_MISSING_OK		(1 << 27) /* Missing argument OK (joined).  */
+#define CL_UINTEGER		(1 << 28) /* Argument is an integer >=0.  */
+#define CL_COMMON		(1 << 29) /* Language-independent.  */
 
 #endif
Index: opts.sh
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.sh,v
retrieving revision 1.14
diff -u -p -b -r1.14 opts.sh
--- opts.sh	15 Jun 2003 19:34:27 -0000	1.14
+++ opts.sh	16 Jun 2003 05:39:20 -0000
@@ -55,8 +55,11 @@ ${AWK} '
 	}
         if (flags ~ " Common ") result = result " | CL_COMMON"
         if (flags ~ " Joined ") result = result " | CL_JOINED"
+        if (flags ~ " JoinedOrMissing ") \
+		result = result " | CL_JOINED | CL_MISSING_OK"
         if (flags ~ " Separate ") result = result " | CL_SEPARATE"
         if (flags ~ " RejectNegative ") result = result " | CL_REJECT_NEGATIVE"
+        if (flags ~ " UInteger ") result = result " | CL_UINTEGER"
 	sub( "^0 \\| ", "", result )
 	return result
     }
Index: java/lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.134
diff -u -p -b -r1.134 lang.c
--- java/lang.c	15 Jun 2003 14:56:31 -0000	1.134
+++ java/lang.c	16 Jun 2003 05:39:21 -0000
@@ -274,17 +274,8 @@ java_handle_option (size_t scode, const 
 
   if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE)))
     {
-      /* These can take an empty argument.  */
-      if (code == OPT_fassume_compiled_
-	  || code == OPT_fclasspath_
-	  || code == OPT_fCLASSPATH_
-	  || code == OPT_fbootclasspath_)
-	arg = "";
-      else
-	{
 	  error ("missing argument to \"-%s\"", option->opt_text);
 	  return 1;
-	}
     }
 
   switch (code)
Index: java/lang.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.opt,v
retrieving revision 1.3
diff -u -p -b -r1.3 lang.opt
--- java/lang.opt	15 Jun 2003 14:56:31 -0000	1.3
+++ java/lang.opt	16 Jun 2003 05:39:21 -0000
@@ -65,7 +65,7 @@ Wredundant-modifiers
 Java
 
 fCLASSPATH=
-Java Joined RejectNegative
+Java JoinedOrMissing RejectNegative
 
 fassert
 Java
@@ -74,16 +74,16 @@ fassume-compiled
 Java
 
 fassume-compiled=
-Java Joined
+Java JoinedOrMissing
 
 fbootclasspath=
-Java Joined RejectNegative
+Java JoinedOrMissing RejectNegative
 
 fcheck-references
 Java
 
 fclasspath=
-Java Joined RejectNegative
+Java JoinedOrMissing RejectNegative
 
 fcompile-resource=
 Java Joined RejectNegative


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]