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
This commit is contained in:
Neil Booth 2003-07-06 19:01:21 +00:00 committed by Neil Booth
parent f55ade6e34
commit cb66e38590
18 changed files with 202 additions and 151 deletions

View File

@ -1,3 +1,28 @@
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.

View File

@ -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.

View File

@ -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:

View File

@ -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);

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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,
@ -87,6 +92,13 @@ hook_bool_tree_hwi_hwi_tree_true (tree a ATTRIBUTE_UNUSED,
return true;
}
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,

View File

@ -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);

View File

@ -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

View File

@ -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:

View File

@ -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, \

View File

@ -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

View File

@ -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

View File

@ -297,107 +297,97 @@ 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
opt_index = find_opt (opt + 1, lang_mask | CL_COMMON);
if (opt_index == cl_options_count)
goto done;
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;
/* We've recognized this switch. */
result = 1;
/* Sort out any argument the switch takes. */
if (option->flags & CL_JOINED)
{
/* Drop the "no-" from negative switches. */
if ((opt[1] == 'W' || opt[1] == 'f')
&& opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
/* 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))
{
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;
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;
/* We've recognized this switch. */
result = 1;
/* 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))
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)))
/* 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)))
{
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))
{
value = integral_argument (arg);
if (value == -1)
{
complain_wrong_lang (argv[0], option, lang_mask);
error ("argument to \"-%s\" should be a non-negative integer",
option->opt_text);
goto done;
}
if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE)))
{
error ("missing argument to \"-%s\"", argv[0]);
goto done;
}
/* 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)
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 (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;
done:
if (dup)
free (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: