Commit cb66e385 by Neil Booth Committed by Neil Booth

c-common.h (c_comon_handle_filename, [...]): New.

	* c-common.h (c_comon_handle_filename,
	c_common_missing_arguement): New.
	* c-lang.c (LANG_HOOKS_HANDLE_FILENAME,
	LANG_HOOKS_MISSING_ARGUMENT): New.
	* c-opts.c (missing_arg): Rename c_common_missing_argument,
	update to be an appropriate langhook.
	(c_common_handle_option): Don't handle filenames.
	(c_common_handle_filename): New.
	* hooks.c (hook_void_constcharptr,
	hook_bool_constcharptr_size_t_false): New.
	* hooks.h (hook_void_constcharptr,
	hook_bool_constcharptr_size_t_false): New.
	* langhooks-def.h (LANG_HOOKS_HANDLE_FILENAME,
	LANG_HOOKS_MISSING_ARGUMENT): New.
	(LANG_HOOKS_INITIALIZER): Update.
	* langhooks.h (struct lang_hooks): Add handle_filename and
	missing_argument.
	* opts.c (handle_option): Don't handle filenames here, but ...
	(handle_options): ... here.
	(common_handle_option): Don't handle missing arguments here.
	* objc/objc-lang.c (LANG_HOOKS_HANDLE_FILENAME,
	LANG_HOOKS_MISSING_ARGUMENT): New.
ada:
	* misc.c (gnat_handle_option): Don't handle filenames.
cp:
	* cp-lang.c (LANG_HOOKS_HANDLE_FILENAME,
	LANG_HOOKS_MISSING_ARGUMENT): Override.
f:
	* top.c (ffe_handle_option): Don't handle filenames.
java:
	* lang.c (java_handle_option): Don't handle filenames.

From-SVN: r69011
parent f55ade6e
2003-07-06 Neil Booth <neil@daikokuya.co.uk> 2003-07-06 Neil Booth <neil@daikokuya.co.uk>
* c-common.h (c_comon_handle_filename,
c_common_missing_arguement): New.
* c-lang.c (LANG_HOOKS_HANDLE_FILENAME,
LANG_HOOKS_MISSING_ARGUMENT): New.
* c-opts.c (missing_arg): Rename c_common_missing_argument,
update to be an appropriate langhook.
(c_common_handle_option): Don't handle filenames.
(c_common_handle_filename): New.
* hooks.c (hook_void_constcharptr,
hook_bool_constcharptr_size_t_false): New.
* hooks.h (hook_void_constcharptr,
hook_bool_constcharptr_size_t_false): New.
* langhooks-def.h (LANG_HOOKS_HANDLE_FILENAME,
LANG_HOOKS_MISSING_ARGUMENT): New.
(LANG_HOOKS_INITIALIZER): Update.
* langhooks.h (struct lang_hooks): Add handle_filename and
missing_argument.
* opts.c (handle_option): Don't handle filenames here, but ...
(handle_options): ... here.
(common_handle_option): Don't handle missing arguments here.
* objc/objc-lang.c (LANG_HOOKS_HANDLE_FILENAME,
LANG_HOOKS_MISSING_ARGUMENT): New.
2003-07-06 Neil Booth <neil@daikokuya.co.uk>
* Makfile.in: Remove traces of mbchar. * Makfile.in: Remove traces of mbchar.
* c-parse.in (MULTIBYTE_CHARS): Remove. * c-parse.in (MULTIBYTE_CHARS): Remove.
* config.in (MULTIBYTE_CHARS): Remove. * config.in (MULTIBYTE_CHARS): Remove.
......
2003-07-06 Neil Booth <neil@daikokuya.co.uk>
* misc.c (gnat_handle_option): Don't handle filenames.
2003-07-04 H.J. Lu <hongjiu.lu@intel.com> 2003-07-04 H.J. Lu <hongjiu.lu@intel.com>
* Make-lang.in: Replace PWD with PWD_COMMAND. * Make-lang.in: Replace PWD with PWD_COMMAND.
......
...@@ -226,10 +226,6 @@ gnat_handle_option (size_t scode, const char *arg, int value ATTRIBUTE_UNUSED) ...@@ -226,10 +226,6 @@ gnat_handle_option (size_t scode, const char *arg, int value ATTRIBUTE_UNUSED)
char *q; char *q;
unsigned int i; unsigned int i;
/* Ignore file names. */
if (code == N_OPTS)
return 1;
switch (code) switch (code)
{ {
default: default:
......
...@@ -896,6 +896,8 @@ extern tree handle_format_attribute (tree *, tree, tree, int, bool *); ...@@ -896,6 +896,8 @@ extern tree handle_format_attribute (tree *, tree, tree, int, bool *);
extern tree handle_format_arg_attribute (tree *, tree, tree, int, bool *); extern tree handle_format_arg_attribute (tree *, tree, tree, int, bool *);
extern void c_common_insert_default_attributes (tree); extern void c_common_insert_default_attributes (tree);
extern int c_common_handle_option (size_t code, const char *arg, int value); extern int c_common_handle_option (size_t code, const char *arg, int value);
extern void c_common_handle_filename (const char *filename);
extern bool c_common_missing_argument (const char *opt, size_t code);
extern tree c_common_type_for_mode (enum machine_mode, int); extern tree c_common_type_for_mode (enum machine_mode, int);
extern tree c_common_type_for_size (unsigned int, int); extern tree c_common_type_for_size (unsigned int, int);
extern tree c_common_unsigned_type (tree); extern tree c_common_unsigned_type (tree);
......
...@@ -45,6 +45,10 @@ enum c_language_kind c_language = clk_c; ...@@ -45,6 +45,10 @@ enum c_language_kind c_language = clk_c;
#define LANG_HOOKS_INIT_OPTIONS c_common_init_options #define LANG_HOOKS_INIT_OPTIONS c_common_init_options
#undef LANG_HOOKS_HANDLE_OPTION #undef LANG_HOOKS_HANDLE_OPTION
#define LANG_HOOKS_HANDLE_OPTION c_common_handle_option #define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
#undef LANG_HOOKS_HANDLE_FILENAME
#define LANG_HOOKS_HANDLE_FILENAME c_common_handle_filename
#undef LANG_HOOKS_MISSING_ARGUMENT
#define LANG_HOOKS_MISSING_ARGUMENT c_common_missing_argument
#undef LANG_HOOKS_POST_OPTIONS #undef LANG_HOOKS_POST_OPTIONS
#define LANG_HOOKS_POST_OPTIONS c_common_post_options #define LANG_HOOKS_POST_OPTIONS c_common_post_options
#undef LANG_HOOKS_GET_ALIAS_SET #undef LANG_HOOKS_GET_ALIAS_SET
......
...@@ -97,7 +97,6 @@ static size_t include_cursor; ...@@ -97,7 +97,6 @@ static size_t include_cursor;
/* Permit Fotran front-end options. */ /* Permit Fotran front-end options. */
static bool permit_fortran_options; static bool permit_fortran_options;
void missing_arg (enum opt_code);
static void set_Wimplicit (int); static void set_Wimplicit (int);
static void print_help (void); static void print_help (void);
static void handle_OPT_d (const char *); static void handle_OPT_d (const char *);
...@@ -125,51 +124,37 @@ static struct deferred_opt ...@@ -125,51 +124,37 @@ static struct deferred_opt
const char *arg; const char *arg;
} *deferred_opts; } *deferred_opts;
/* Complain that switch OPT_INDEX expects an argument but none was /* Complain that switch CODE expects an argument but none was
provided. */ provided. OPT was the command-line option. Return FALSE to get
void the default message in opts.c, TRUE if we provide a specialized
missing_arg (enum opt_code code) one. */
bool
c_common_missing_argument (const char *opt, size_t code)
{ {
const char *opt_text = cl_options[code].opt_text;
switch (code) switch (code)
{ {
case OPT__output_pch_:
case OPT_Wformat_:
case OPT_d:
case OPT_fabi_version_:
case OPT_fbuiltin_:
case OPT_fdump_:
case OPT_fname_mangling_version_:
case OPT_ftabstop_:
case OPT_fexec_charset_:
case OPT_fwide_exec_charset_:
case OPT_ftemplate_depth_:
case OPT_iprefix:
case OPT_iwithprefix:
case OPT_iwithprefixbefore:
default: default:
error ("missing argument to \"-%s\"", opt_text); /* Pick up the default message. */
break; return false;
case OPT_fconstant_string_class_: case OPT_fconstant_string_class_:
error ("no class name specified with \"-%s\"", opt_text); error ("no class name specified with \"%s\"", opt);
break; break;
case OPT_A: case OPT_A:
error ("assertion missing after \"-%s\"", opt_text); error ("assertion missing after \"%s\"", opt);
break; break;
case OPT_D: case OPT_D:
case OPT_U: case OPT_U:
error ("macro name missing after \"-%s\"", opt_text); error ("macro name missing after \"%s\"", opt);
break; break;
case OPT_I: case OPT_I:
case OPT_idirafter: case OPT_idirafter:
case OPT_isysroot: case OPT_isysroot:
case OPT_isystem: case OPT_isystem:
error ("missing path after \"-%s\"", opt_text); error ("missing path after \"%s\"", opt);
break; break;
case OPT_MF: case OPT_MF:
...@@ -178,14 +163,16 @@ missing_arg (enum opt_code code) ...@@ -178,14 +163,16 @@ missing_arg (enum opt_code code)
case OPT_include: case OPT_include:
case OPT_imacros: case OPT_imacros:
case OPT_o: case OPT_o:
error ("missing filename after \"-%s\"", opt_text); error ("missing filename after \"%s\"", opt);
break; break;
case OPT_MQ: case OPT_MQ:
case OPT_MT: case OPT_MT:
error ("missing target after \"-%s\"", opt_text); error ("missing makefile target after \"%s\"", opt);
break; break;
} }
return true;
} }
/* Defer option CODE with argument ARG. */ /* Defer option CODE with argument ARG. */
...@@ -261,18 +248,6 @@ c_common_handle_option (size_t scode, const char *arg, int value) ...@@ -261,18 +248,6 @@ c_common_handle_option (size_t scode, const char *arg, int value)
enum opt_code code = (enum opt_code) scode; enum opt_code code = (enum opt_code) scode;
int result = 1; int result = 1;
if (code == N_OPTS)
{
if (!in_fname)
in_fname = arg;
else if (!out_fname)
out_fname = arg;
else
error ("too many filenames given. Type %s --help for usage",
progname);
return 1;
}
switch (code) switch (code)
{ {
default: default:
...@@ -700,7 +675,7 @@ c_common_handle_option (size_t scode, const char *arg, int value) ...@@ -700,7 +675,7 @@ c_common_handle_option (size_t scode, const char *arg, int value)
case OPT_fthis_is_variable: case OPT_fthis_is_variable:
case OPT_fvtable_thunks: case OPT_fvtable_thunks:
case OPT_fxref: case OPT_fxref:
warning ("switch \"%s\" is no longer supported", option->opt_text); warning ("switch \"-%s\" is no longer supported", option->opt_text);
break; break;
case OPT_fabi_version_: case OPT_fabi_version_:
...@@ -716,7 +691,8 @@ c_common_handle_option (size_t scode, const char *arg, int value) ...@@ -716,7 +691,8 @@ c_common_handle_option (size_t scode, const char *arg, int value)
if (value) if (value)
flag_external_templates = true; flag_external_templates = true;
cp_deprecated: cp_deprecated:
warning ("switch \"%s\" is deprecated, please see documentation for details", option->opt_text); warning ("switch \"-%s\" is deprecated, please see documentation "
"for details", option->opt_text);
break; break;
case OPT_fasm: case OPT_fasm:
...@@ -1059,6 +1035,18 @@ c_common_handle_option (size_t scode, const char *arg, int value) ...@@ -1059,6 +1035,18 @@ c_common_handle_option (size_t scode, const char *arg, int value)
return result; return result;
} }
/* Handle FILENAME from the command line. */
void
c_common_handle_filename (const char *filename)
{
if (!in_fname)
in_fname = filename;
else if (!out_fname)
out_fname = filename;
else
error ("output filename specified twice");
}
/* Post-switch processing. */ /* Post-switch processing. */
bool bool
c_common_post_options (const char **pfilename) c_common_post_options (const char **pfilename)
......
2003-07-06 Neil Booth <neil@daikokuya.co.uk>
* cp-lang.c (LANG_HOOKS_HANDLE_FILENAME,
LANG_HOOKS_MISSING_ARGUMENT): Override.
2003-07-05 Mark Mitchell <mark@codesourcery.com> 2003-07-05 Mark Mitchell <mark@codesourcery.com>
PR c++/11431 PR c++/11431
......
...@@ -53,6 +53,10 @@ static bool cp_var_mod_type_p (tree); ...@@ -53,6 +53,10 @@ static bool cp_var_mod_type_p (tree);
#define LANG_HOOKS_INIT_OPTIONS c_common_init_options #define LANG_HOOKS_INIT_OPTIONS c_common_init_options
#undef LANG_HOOKS_HANDLE_OPTION #undef LANG_HOOKS_HANDLE_OPTION
#define LANG_HOOKS_HANDLE_OPTION c_common_handle_option #define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
#undef LANG_HOOKS_HANDLE_FILENAME
#define LANG_HOOKS_HANDLE_FILENAME c_common_handle_filename
#undef LANG_HOOKS_MISSING_ARGUMENT
#define LANG_HOOKS_MISSING_ARGUMENT c_common_missing_argument
#undef LANG_HOOKS_POST_OPTIONS #undef LANG_HOOKS_POST_OPTIONS
#define LANG_HOOKS_POST_OPTIONS c_common_post_options #define LANG_HOOKS_POST_OPTIONS c_common_post_options
#undef LANG_HOOKS_GET_ALIAS_SET #undef LANG_HOOKS_GET_ALIAS_SET
......
Sun Jul 6 20:01:29 2003 Neil Booth <neil@daikokuya.co.uk>
* top.c (ffe_handle_option): Don't handle filenames.
2003-07-05 Toon Moene <toon@moene.indiv.nluug.nl> 2003-07-05 Toon Moene <toon@moene.indiv.nluug.nl>
PR Fortran/11301 PR Fortran/11301
......
...@@ -178,10 +178,6 @@ ffe_handle_option (size_t scode, const char *arg, int value) ...@@ -178,10 +178,6 @@ ffe_handle_option (size_t scode, const char *arg, int value)
{ {
enum opt_code code = (enum opt_code) scode; enum opt_code code = (enum opt_code) scode;
/* Ignore file names. */
if (code == N_OPTS)
return 1;
switch (code) switch (code)
{ {
default: default:
......
...@@ -68,6 +68,11 @@ hook_void_FILEptr_constcharptr (FILE *a ATTRIBUTE_UNUSED, const char *b ATTRIBUT ...@@ -68,6 +68,11 @@ hook_void_FILEptr_constcharptr (FILE *a ATTRIBUTE_UNUSED, const char *b ATTRIBUT
{ {
} }
void
hook_void_constcharptr (const char *a ATTRIBUTE_UNUSED)
{
}
/* Used for the TARGET_ASM_CAN_OUTPUT_MI_THUNK hook. */ /* Used for the TARGET_ASM_CAN_OUTPUT_MI_THUNK hook. */
bool bool
hook_bool_tree_hwi_hwi_tree_false (tree a ATTRIBUTE_UNUSED, hook_bool_tree_hwi_hwi_tree_false (tree a ATTRIBUTE_UNUSED,
...@@ -88,6 +93,13 @@ hook_bool_tree_hwi_hwi_tree_true (tree a ATTRIBUTE_UNUSED, ...@@ -88,6 +93,13 @@ hook_bool_tree_hwi_hwi_tree_true (tree a ATTRIBUTE_UNUSED,
} }
bool bool
hook_bool_constcharptr_size_t_false (const char *a ATTRIBUTE_UNUSED,
size_t b ATTRIBUTE_UNUSED)
{
return false;
}
bool
default_can_output_mi_thunk_no_vcall (tree a ATTRIBUTE_UNUSED, default_can_output_mi_thunk_no_vcall (tree a ATTRIBUTE_UNUSED,
HOST_WIDE_INT b ATTRIBUTE_UNUSED, HOST_WIDE_INT b ATTRIBUTE_UNUSED,
HOST_WIDE_INT c, HOST_WIDE_INT c,
......
...@@ -31,12 +31,14 @@ bool hook_bool_tree_hwi_hwi_tree_true (tree, HOST_WIDE_INT, HOST_WIDE_INT, ...@@ -31,12 +31,14 @@ bool hook_bool_tree_hwi_hwi_tree_true (tree, HOST_WIDE_INT, HOST_WIDE_INT,
tree); tree);
bool hook_bool_rtx_false (rtx); bool hook_bool_rtx_false (rtx);
bool hook_bool_rtx_int_int_intp_false (rtx, int, int, int *); bool hook_bool_rtx_int_int_intp_false (rtx, int, int, int *);
bool hook_bool_constcharptr_size_t_false (const char *, size_t);
void hook_void_tree_int (tree, int); void hook_void_tree_int (tree, int);
void hook_void_void (void); void hook_void_void (void);
void hook_void_FILEptr_constcharptr (FILE *, const char *); void hook_void_FILEptr_constcharptr (FILE *, const char *);
void hook_void_tree (tree); void hook_void_tree (tree);
void hook_void_tree_treeptr (tree, tree *); void hook_void_tree_treeptr (tree, tree *);
void hook_void_constcharptr (const char *);
int hook_int_tree_tree_1 (tree, tree); int hook_int_tree_tree_1 (tree, tree);
int hook_int_rtx_0 (rtx); int hook_int_rtx_0 (rtx);
......
2003-07-06 Neil Booth <neil@daikokuya.co.uk>
* lang.c (java_handle_option): Don't handle filenames.
2003-07-02 Zack Weinberg <zack@codesourcery.com> 2003-07-02 Zack Weinberg <zack@codesourcery.com>
* jcf-path.c: Don't default-define PATH_SEPARATOR nor * jcf-path.c: Don't default-define PATH_SEPARATOR nor
......
...@@ -267,10 +267,6 @@ java_handle_option (size_t scode, const char *arg, int value) ...@@ -267,10 +267,6 @@ java_handle_option (size_t scode, const char *arg, int value)
{ {
enum opt_code code = (enum opt_code) scode; enum opt_code code = (enum opt_code) scode;
/* Ignore file names. */
if (code == N_OPTS)
return 1;
switch (code) switch (code)
{ {
default: default:
......
...@@ -90,6 +90,8 @@ extern void write_global_declarations (void); ...@@ -90,6 +90,8 @@ extern void write_global_declarations (void);
#define LANG_HOOKS_CLEAR_BINDING_STACK lhd_clear_binding_stack #define LANG_HOOKS_CLEAR_BINDING_STACK lhd_clear_binding_stack
#define LANG_HOOKS_INIT_OPTIONS hook_uint_uint_constcharptrptr_0 #define LANG_HOOKS_INIT_OPTIONS hook_uint_uint_constcharptrptr_0
#define LANG_HOOKS_HANDLE_OPTION hook_int_size_t_constcharptr_int_0 #define LANG_HOOKS_HANDLE_OPTION hook_int_size_t_constcharptr_int_0
#define LANG_HOOKS_HANDLE_FILENAME hook_void_constcharptr
#define LANG_HOOKS_MISSING_ARGUMENT hook_bool_constcharptr_size_t_false
#define LANG_HOOKS_POST_OPTIONS lhd_post_options #define LANG_HOOKS_POST_OPTIONS lhd_post_options
#define LANG_HOOKS_GET_ALIAS_SET lhd_get_alias_set #define LANG_HOOKS_GET_ALIAS_SET lhd_get_alias_set
#define LANG_HOOKS_EXPAND_CONSTANT lhd_return_tree #define LANG_HOOKS_EXPAND_CONSTANT lhd_return_tree
...@@ -244,6 +246,8 @@ extern int lhd_tree_dump_type_quals (tree); ...@@ -244,6 +246,8 @@ extern int lhd_tree_dump_type_quals (tree);
LANG_HOOKS_TREE_SIZE, \ LANG_HOOKS_TREE_SIZE, \
LANG_HOOKS_INIT_OPTIONS, \ LANG_HOOKS_INIT_OPTIONS, \
LANG_HOOKS_HANDLE_OPTION, \ LANG_HOOKS_HANDLE_OPTION, \
LANG_HOOKS_HANDLE_FILENAME, \
LANG_HOOKS_MISSING_ARGUMENT, \
LANG_HOOKS_POST_OPTIONS, \ LANG_HOOKS_POST_OPTIONS, \
LANG_HOOKS_INIT, \ LANG_HOOKS_INIT, \
LANG_HOOKS_FINISH, \ LANG_HOOKS_FINISH, \
......
...@@ -217,6 +217,13 @@ struct lang_hooks ...@@ -217,6 +217,13 @@ struct lang_hooks
valid and should not be treated as language-independent too. */ valid and should not be treated as language-independent too. */
int (*handle_option) (size_t code, const char *arg, int value); int (*handle_option) (size_t code, const char *arg, int value);
/* Handle a filename on the command line. */
void (*handle_filename) (const char *filename);
/* Return false to use the default complaint about a missing
argument, otherwise output a complaint and return true. */
bool (*missing_argument) (const char *opt, size_t code);
/* Called when all command line options have been parsed to allow /* Called when all command line options have been parsed to allow
further processing and initialization further processing and initialization
......
...@@ -43,6 +43,10 @@ enum c_language_kind c_language = clk_objc; ...@@ -43,6 +43,10 @@ enum c_language_kind c_language = clk_objc;
#define LANG_HOOKS_INIT_OPTIONS c_common_init_options #define LANG_HOOKS_INIT_OPTIONS c_common_init_options
#undef LANG_HOOKS_HANDLE_OPTION #undef LANG_HOOKS_HANDLE_OPTION
#define LANG_HOOKS_HANDLE_OPTION c_common_handle_option #define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
#undef LANG_HOOKS_HANDLE_FILENAME
#define LANG_HOOKS_HANDLE_FILENAME c_common_handle_filename
#undef LANG_HOOKS_MISSING_ARGUMENT
#define LANG_HOOKS_MISSING_ARGUMENT c_common_missing_argument
#undef LANG_HOOKS_POST_OPTIONS #undef LANG_HOOKS_POST_OPTIONS
#define LANG_HOOKS_POST_OPTIONS c_common_post_options #define LANG_HOOKS_POST_OPTIONS c_common_post_options
#undef LANG_HOOKS_GET_ALIAS_SET #undef LANG_HOOKS_GET_ALIAS_SET
......
...@@ -297,106 +297,96 @@ handle_option (const char **argv, unsigned int lang_mask) ...@@ -297,106 +297,96 @@ handle_option (const char **argv, unsigned int lang_mask)
opt = argv[0]; opt = argv[0];
/* Interpret "-" or a non-switch as a file name. */ /* Drop the "no-" from negative switches. */
if (opt[0] != '-' || opt[1] == '\0') if ((opt[1] == 'W' || opt[1] == 'f')
&& opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
{ {
opt_index = cl_options_count; size_t len = strlen (opt) - 3;
arg = opt;
main_input_filename = opt; dup = xmalloc (len + 1);
result = (*lang_hooks.handle_option) (opt_index, arg, value); dup[0] = '-';
dup[1] = opt[1];
memcpy (dup + 2, opt + 5, len - 2 + 1);
opt = dup;
value = 0;
} }
else
{
/* Drop the "no-" from negative switches. */
if ((opt[1] == 'W' || opt[1] == 'f')
&& opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
{
size_t len = strlen (opt) - 3;
dup = xmalloc (len + 1);
dup[0] = '-';
dup[1] = opt[1];
memcpy (dup + 2, opt + 5, len - 2 + 1);
opt = dup;
value = 0;
}
opt_index = find_opt (opt + 1, lang_mask | CL_COMMON); opt_index = find_opt (opt + 1, lang_mask | CL_COMMON);
if (opt_index == cl_options_count) if (opt_index == cl_options_count)
goto done; goto done;
option = &cl_options[opt_index]; option = &cl_options[opt_index];
/* Reject negative form of switches that don't take negatives as /* Reject negative form of switches that don't take negatives as
unrecognized. */ unrecognized. */
if (!value && (option->flags & CL_REJECT_NEGATIVE)) if (!value && (option->flags & CL_REJECT_NEGATIVE))
goto done; goto done;
/* We've recognized this switch. */ /* We've recognized this switch. */
result = 1; result = 1;
/* Sort out any argument the switch takes. */ /* Sort out any argument the switch takes. */
if (option->flags & CL_JOINED) 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 (!value)
arg += strlen ("no-");
if (*arg == '\0' && !(option->flags & CL_MISSING_OK))
{ {
/* Have arg point to the original switch. This is because if (option->flags & CL_SEPARATE)
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 (!value)
arg += strlen ("no-");
if (*arg == '\0' && !(option->flags & CL_MISSING_OK))
{ {
if (option->flags & CL_SEPARATE) arg = argv[1];
{ result = 2;
arg = argv[1];
result = 2;
}
else
/* Missing argument. */
arg = NULL;
} }
else
/* Missing argument. */
arg = NULL;
} }
else if (option->flags & CL_SEPARATE) }
{ else if (option->flags & CL_SEPARATE)
arg = argv[1]; {
result = 2; arg = argv[1];
} result = 2;
}
/* Now we've swallowed any potential argument, complain if this /* Now we've swallowed any potential argument, complain if this
is a switch for a different front end. */ is a switch for a different front end. */
if (!(option->flags & (lang_mask | CL_COMMON))) if (!(option->flags & (lang_mask | CL_COMMON)))
{ {
complain_wrong_lang (argv[0], option, lang_mask); complain_wrong_lang (argv[0], option, lang_mask);
goto done; goto done;
} }
if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE))) if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE)))
{ {
error ("missing argument to \"-%s\"", argv[0]); if (!(*lang_hooks.missing_argument) (opt, opt_index))
goto done; error ("missing argument to \"%s\"", opt);
} goto done;
}
/* If the switch takes an integer, convert it. */ /* If the switch takes an integer, convert it. */
if (arg && (option->flags & CL_UINTEGER)) if (arg && (option->flags & CL_UINTEGER))
{
value = integral_argument (arg);
if (value == -1)
{ {
value = integral_argument (arg); error ("argument to \"-%s\" should be a non-negative integer",
if (value == -1) option->opt_text);
{ goto done;
error ("argument to \"-%s\" should be a non-negative integer",
option->opt_text);
goto done;
}
} }
}
if (option->flags & lang_mask) if (option->flags & lang_mask)
if ((*lang_hooks.handle_option) (opt_index, arg, value) == 0) if ((*lang_hooks.handle_option) (opt_index, arg, value) == 0)
result = 0; result = 0;
if (result && (option->flags & CL_COMMON)) if (result && (option->flags & CL_COMMON))
if (common_handle_option (opt_index, arg, value) == 0) if (common_handle_option (opt_index, arg, value) == 0)
result = 0; result = 0;
}
done: done:
if (dup) if (dup)
...@@ -414,12 +404,23 @@ handle_options (unsigned int argc, const char **argv, unsigned int lang_mask) ...@@ -414,12 +404,23 @@ handle_options (unsigned int argc, const char **argv, unsigned int lang_mask)
for (i = 1; i < argc; i += n) for (i = 1; i < argc; i += n)
{ {
const char *opt = argv[i];
/* Interpret "-" or a non-switch as a file name. */
if (opt[0] != '-' || opt[1] == '\0')
{
main_input_filename = opt;
(*lang_hooks.handle_filename) (opt);
n = 1;
continue;
}
n = handle_option (argv + i, lang_mask); n = handle_option (argv + i, lang_mask);
if (!n) if (!n)
{ {
n = 1; n = 1;
error ("unrecognized command line option \"%s\"", argv[i]); error ("unrecognized command line option \"%s\"", opt);
} }
} }
} }
...@@ -603,15 +604,8 @@ static int ...@@ -603,15 +604,8 @@ static int
common_handle_option (size_t scode, const char *arg, common_handle_option (size_t scode, const char *arg,
int value ATTRIBUTE_UNUSED) int value ATTRIBUTE_UNUSED)
{ {
const struct cl_option *option = &cl_options[scode];
enum opt_code code = (enum opt_code) scode; enum opt_code code = (enum opt_code) scode;
if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE)))
{
error ("missing argument to \"-%s\"", option->opt_text);
return 1;
}
switch (code) switch (code)
{ {
default: default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment