diff options
author | Neil Booth <neil@daikokuya.co.uk> | 2003-07-06 19:01:21 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2003-07-06 19:01:21 +0000 |
commit | cb66e3859075ec552fbb04ca253455c46e760696 (patch) | |
tree | 2c35f94351c2c6323b73a7de33df3a43dba7c2d2 | |
parent | f55ade6e34ae3da57dd1a270c4bee55ad4f85cf5 (diff) | |
download | gcc-cb66e3859075ec552fbb04ca253455c46e760696.zip gcc-cb66e3859075ec552fbb04ca253455c46e760696.tar.gz gcc-cb66e3859075ec552fbb04ca253455c46e760696.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 25 | ||||
-rw-r--r-- | gcc/ada/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/ada/misc.c | 4 | ||||
-rw-r--r-- | gcc/c-common.h | 2 | ||||
-rw-r--r-- | gcc/c-lang.c | 4 | ||||
-rw-r--r-- | gcc/c-opts.c | 74 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/cp-lang.c | 4 | ||||
-rw-r--r-- | gcc/f/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/f/top.c | 4 | ||||
-rw-r--r-- | gcc/hooks.c | 12 | ||||
-rw-r--r-- | gcc/hooks.h | 2 | ||||
-rw-r--r-- | gcc/java/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/java/lang.c | 4 | ||||
-rw-r--r-- | gcc/langhooks-def.h | 4 | ||||
-rw-r--r-- | gcc/langhooks.h | 7 | ||||
-rw-r--r-- | gcc/objc/objc-lang.c | 4 | ||||
-rw-r--r-- | gcc/opts.c | 174 |
18 files changed, 196 insertions, 145 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e0c44eb..c93c750 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,30 @@ 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. * c-parse.in (MULTIBYTE_CHARS): Remove. * config.in (MULTIBYTE_CHARS): Remove. diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 53916bb..467111f 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,7 @@ +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> * Make-lang.in: Replace PWD with PWD_COMMAND. diff --git a/gcc/ada/misc.c b/gcc/ada/misc.c index ca9a036..60232bf 100644 --- a/gcc/ada/misc.c +++ b/gcc/ada/misc.c @@ -226,10 +226,6 @@ gnat_handle_option (size_t scode, const char *arg, int value ATTRIBUTE_UNUSED) char *q; unsigned int i; - /* Ignore file names. */ - if (code == N_OPTS) - return 1; - switch (code) { default: diff --git a/gcc/c-common.h b/gcc/c-common.h index d1c3e5a..bafe857 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -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 void c_common_insert_default_attributes (tree); 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_size (unsigned int, int); extern tree c_common_unsigned_type (tree); diff --git a/gcc/c-lang.c b/gcc/c-lang.c index 5da15e5..99b01ec 100644 --- a/gcc/c-lang.c +++ b/gcc/c-lang.c @@ -45,6 +45,10 @@ enum c_language_kind c_language = clk_c; #define LANG_HOOKS_INIT_OPTIONS c_common_init_options #undef LANG_HOOKS_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 #define LANG_HOOKS_POST_OPTIONS c_common_post_options #undef LANG_HOOKS_GET_ALIAS_SET diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 3bccc7e..063e6e2 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -97,7 +97,6 @@ static size_t include_cursor; /* Permit Fotran front-end options. */ static bool permit_fortran_options; -void missing_arg (enum opt_code); static void set_Wimplicit (int); static void print_help (void); static void handle_OPT_d (const char *); @@ -125,51 +124,37 @@ static struct deferred_opt const char *arg; } *deferred_opts; -/* Complain that switch OPT_INDEX expects an argument but none was - provided. */ -void -missing_arg (enum opt_code code) +/* Complain that switch CODE expects an argument but none was + provided. OPT was the command-line option. Return FALSE to get + the default message in opts.c, TRUE if we provide a specialized + one. */ +bool +c_common_missing_argument (const char *opt, size_t code) { - const char *opt_text = cl_options[code].opt_text; - 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: - error ("missing argument to \"-%s\"", opt_text); - break; + /* Pick up the default message. */ + return false; case OPT_fconstant_string_class_: - error ("no class name specified with \"-%s\"", opt_text); + error ("no class name specified with \"%s\"", opt); break; case OPT_A: - error ("assertion missing after \"-%s\"", opt_text); + error ("assertion missing after \"%s\"", opt); break; case OPT_D: case OPT_U: - error ("macro name missing after \"-%s\"", opt_text); + error ("macro name missing after \"%s\"", opt); break; case OPT_I: case OPT_idirafter: case OPT_isysroot: case OPT_isystem: - error ("missing path after \"-%s\"", opt_text); + error ("missing path after \"%s\"", opt); break; case OPT_MF: @@ -178,14 +163,16 @@ missing_arg (enum opt_code code) case OPT_include: case OPT_imacros: case OPT_o: - error ("missing filename after \"-%s\"", opt_text); + error ("missing filename after \"%s\"", opt); break; case OPT_MQ: case OPT_MT: - error ("missing target after \"-%s\"", opt_text); + error ("missing makefile target after \"%s\"", opt); break; } + + return true; } /* Defer option CODE with argument ARG. */ @@ -261,18 +248,6 @@ c_common_handle_option (size_t scode, const char *arg, int value) enum opt_code code = (enum opt_code) scode; 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) { default: @@ -700,7 +675,7 @@ c_common_handle_option (size_t scode, const char *arg, int value) case OPT_fthis_is_variable: case OPT_fvtable_thunks: case OPT_fxref: - warning ("switch \"%s\" is no longer supported", option->opt_text); + warning ("switch \"-%s\" is no longer supported", option->opt_text); break; case OPT_fabi_version_: @@ -716,7 +691,8 @@ c_common_handle_option (size_t scode, const char *arg, int value) if (value) flag_external_templates = true; 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; case OPT_fasm: @@ -1059,6 +1035,18 @@ c_common_handle_option (size_t scode, const char *arg, int value) 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. */ bool c_common_post_options (const char **pfilename) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 62d989d..63227de 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +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> PR c++/11431 diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c index 78a4e6b..affc964 100644 --- a/gcc/cp/cp-lang.c +++ b/gcc/cp/cp-lang.c @@ -53,6 +53,10 @@ static bool cp_var_mod_type_p (tree); #define LANG_HOOKS_INIT_OPTIONS c_common_init_options #undef LANG_HOOKS_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 #define LANG_HOOKS_POST_OPTIONS c_common_post_options #undef LANG_HOOKS_GET_ALIAS_SET diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog index 1203559..34483fe 100644 --- a/gcc/f/ChangeLog +++ b/gcc/f/ChangeLog @@ -1,3 +1,7 @@ +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> PR Fortran/11301 diff --git a/gcc/f/top.c b/gcc/f/top.c index 30b6eb2..81d6c68 100644 --- a/gcc/f/top.c +++ b/gcc/f/top.c @@ -178,10 +178,6 @@ ffe_handle_option (size_t scode, const char *arg, int value) { enum opt_code code = (enum opt_code) scode; - /* Ignore file names. */ - if (code == N_OPTS) - return 1; - switch (code) { default: diff --git a/gcc/hooks.c b/gcc/hooks.c index d737000..c022eb3 100644 --- a/gcc/hooks.c +++ b/gcc/hooks.c @@ -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. */ bool 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, } 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, HOST_WIDE_INT b ATTRIBUTE_UNUSED, HOST_WIDE_INT c, diff --git a/gcc/hooks.h b/gcc/hooks.h index 4309a5d..6fa0bbe 100644 --- a/gcc/hooks.h +++ b/gcc/hooks.h @@ -31,12 +31,14 @@ bool hook_bool_tree_hwi_hwi_tree_true (tree, HOST_WIDE_INT, HOST_WIDE_INT, tree); bool hook_bool_rtx_false (rtx); 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_void (void); void hook_void_FILEptr_constcharptr (FILE *, const char *); void hook_void_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_rtx_0 (rtx); diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index db3a7b0..8627d26 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,7 @@ +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> * jcf-path.c: Don't default-define PATH_SEPARATOR nor diff --git a/gcc/java/lang.c b/gcc/java/lang.c index 7137bcf..7402ab7 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -267,10 +267,6 @@ java_handle_option (size_t scode, const char *arg, int value) { enum opt_code code = (enum opt_code) scode; - /* Ignore file names. */ - if (code == N_OPTS) - return 1; - switch (code) { default: diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index 4995d4a..a598c05 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -90,6 +90,8 @@ extern void write_global_declarations (void); #define LANG_HOOKS_CLEAR_BINDING_STACK lhd_clear_binding_stack #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_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_GET_ALIAS_SET lhd_get_alias_set #define LANG_HOOKS_EXPAND_CONSTANT lhd_return_tree @@ -244,6 +246,8 @@ extern int lhd_tree_dump_type_quals (tree); LANG_HOOKS_TREE_SIZE, \ LANG_HOOKS_INIT_OPTIONS, \ LANG_HOOKS_HANDLE_OPTION, \ + LANG_HOOKS_HANDLE_FILENAME, \ + LANG_HOOKS_MISSING_ARGUMENT, \ LANG_HOOKS_POST_OPTIONS, \ LANG_HOOKS_INIT, \ LANG_HOOKS_FINISH, \ diff --git a/gcc/langhooks.h b/gcc/langhooks.h index df3dab1..1ba3bfe 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -217,6 +217,13 @@ struct lang_hooks valid and should not be treated as language-independent too. */ 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 further processing and initialization diff --git a/gcc/objc/objc-lang.c b/gcc/objc/objc-lang.c index 4457ee8..99e3967 100644 --- a/gcc/objc/objc-lang.c +++ b/gcc/objc/objc-lang.c @@ -43,6 +43,10 @@ enum c_language_kind c_language = clk_objc; #define LANG_HOOKS_INIT_OPTIONS c_common_init_options #undef LANG_HOOKS_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 #define LANG_HOOKS_POST_OPTIONS c_common_post_options #undef LANG_HOOKS_GET_ALIAS_SET @@ -297,106 +297,96 @@ handle_option (const char **argv, unsigned int lang_mask) opt = argv[0]; - /* Interpret "-" or a non-switch as a file name. */ - if (opt[0] != '-' || opt[1] == '\0') + /* Drop the "no-" from negative switches. */ + if ((opt[1] == 'W' || opt[1] == 'f') + && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-') { - opt_index = cl_options_count; - arg = opt; - main_input_filename = opt; - result = (*lang_hooks.handle_option) (opt_index, arg, value); + 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; } - 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); - if (opt_index == cl_options_count) - goto done; + opt_index = find_opt (opt + 1, lang_mask | CL_COMMON); + if (opt_index == cl_options_count) + goto done; - option = &cl_options[opt_index]; + option = &cl_options[opt_index]; - /* Reject negative form of switches that don't take negatives as - unrecognized. */ - if (!value && (option->flags & CL_REJECT_NEGATIVE)) - goto done; + /* Reject negative form of switches that don't take negatives as + unrecognized. */ + if (!value && (option->flags & CL_REJECT_NEGATIVE)) + goto done; - /* We've recognized this switch. */ - result = 1; + /* We've recognized this switch. */ + result = 1; - /* Sort out any argument the switch takes. */ - if (option->flags & CL_JOINED) + /* Sort out any argument the switch takes. */ + 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 - 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) { - if (option->flags & CL_SEPARATE) - { - arg = argv[1]; - result = 2; - } - else - /* Missing argument. */ - arg = NULL; + arg = argv[1]; + result = 2; } + else + /* Missing argument. */ + arg = NULL; } - else if (option->flags & CL_SEPARATE) - { - arg = argv[1]; - result = 2; - } + } + else if (option->flags & CL_SEPARATE) + { + arg = argv[1]; + result = 2; + } - /* Now we've swallowed any potential argument, complain if this - is a switch for a different front end. */ - if (!(option->flags & (lang_mask | CL_COMMON))) - { - complain_wrong_lang (argv[0], option, lang_mask); - goto done; - } + /* Now we've swallowed any potential argument, complain if this + is a switch for a different front end. */ + if (!(option->flags & (lang_mask | CL_COMMON))) + { + complain_wrong_lang (argv[0], option, lang_mask); + goto done; + } - if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE))) - { - error ("missing argument to \"-%s\"", argv[0]); - goto done; - } + if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE))) + { + if (!(*lang_hooks.missing_argument) (opt, opt_index)) + error ("missing argument to \"%s\"", opt); + goto done; + } - /* If the switch takes an integer, convert it. */ - if (arg && (option->flags & CL_UINTEGER)) + /* If the switch takes an integer, convert it. */ + if (arg && (option->flags & CL_UINTEGER)) + { + value = integral_argument (arg); + if (value == -1) { - value = integral_argument (arg); - if (value == -1) - { - error ("argument to \"-%s\" should be a non-negative integer", - 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 ((*lang_hooks.handle_option) (opt_index, arg, value) == 0) - result = 0; + if (option->flags & lang_mask) + if ((*lang_hooks.handle_option) (opt_index, arg, value) == 0) + result = 0; - if (result && (option->flags & CL_COMMON)) - if (common_handle_option (opt_index, arg, value) == 0) - result = 0; - } + if (result && (option->flags & CL_COMMON)) + if (common_handle_option (opt_index, arg, value) == 0) + result = 0; done: if (dup) @@ -414,12 +404,23 @@ handle_options (unsigned int argc, const char **argv, unsigned int lang_mask) 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); if (!n) { n = 1; - error ("unrecognized command line option \"%s\"", argv[i]); + error ("unrecognized command line option \"%s\"", opt); } } } @@ -603,15 +604,8 @@ static int common_handle_option (size_t scode, const char *arg, int value ATTRIBUTE_UNUSED) { - const struct cl_option *option = &cl_options[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) { default: |