Makefile.in: Update.
* Makefile.in: Update. * common.opt: New options. * opts.c (maybe_warn_unused_parameter, set_Wextra, handle_param, set_Wunused): New. (common_handle_option): Handle new options. * toplev.c (set_target_switch): Export. (set_Wextra, set_Wunused, maybe_warn_unused_parameter): Move to opts.c. (decode_W_option): -Wunused and -Wextra handled in opts.c now. (independent_decode_option): More options handled in opts.c now. Change prototype. * toplev.h (set_target_switch): New. From-SVN: r68138
This commit is contained in:
parent
f3f735eb70
commit
903caebf49
@ -1,3 +1,17 @@
|
||||
2003-06-18 Neil Booth <neil@daikokuya.co.uk>
|
||||
|
||||
* Makefile.in: Update.
|
||||
* common.opt: New options.
|
||||
* opts.c (maybe_warn_unused_parameter, set_Wextra, handle_param,
|
||||
set_Wunused): New.
|
||||
(common_handle_option): Handle new options.
|
||||
* toplev.c (set_target_switch): Export.
|
||||
(set_Wextra, set_Wunused, maybe_warn_unused_parameter): Move to opts.c.
|
||||
(decode_W_option): -Wunused and -Wextra handled in opts.c now.
|
||||
(independent_decode_option): More options handled in opts.c now.
|
||||
Change prototype.
|
||||
* toplev.h (set_target_switch): New.
|
||||
|
||||
2003-06-17 Robert Abeles <rabeles@archaelogic.com>
|
||||
|
||||
PR debug/4252
|
||||
|
@ -1318,7 +1318,7 @@ c-pretty-print.o : c-pretty-print.c c-pretty-print.h pretty-print.h \
|
||||
|
||||
c-opts.o : c-opts.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
|
||||
c-pragma.h flags.h toplev.h langhooks.h tree-inline.h diagnostic.h \
|
||||
intl.h debug.h $(C_COMMON_H) opts.h options.h
|
||||
intl.h debug.h $(C_COMMON_H) opts.h options.h params.h
|
||||
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
|
||||
$< $(OUTPUT_OPTION) @TARGET_SYSTEM_ROOT_DEFINE@
|
||||
|
||||
|
@ -25,6 +25,9 @@
|
||||
-help
|
||||
Common
|
||||
|
||||
-param
|
||||
Common Separate
|
||||
|
||||
-target-help
|
||||
Common
|
||||
|
||||
@ -34,6 +37,21 @@ Common
|
||||
G
|
||||
Common Joined Separate UInteger
|
||||
|
||||
O
|
||||
Common JoinedOrMissing
|
||||
|
||||
Os
|
||||
Common
|
||||
|
||||
W
|
||||
Common RejectNegative
|
||||
|
||||
Wextra
|
||||
Common
|
||||
|
||||
Wunused
|
||||
Common
|
||||
|
||||
aux-info
|
||||
Common Separate
|
||||
|
||||
@ -52,6 +70,9 @@ Common Joined
|
||||
dumpbase
|
||||
Common Separate
|
||||
|
||||
m
|
||||
Common Joined
|
||||
|
||||
o
|
||||
Common Joined Separate
|
||||
|
||||
|
92
gcc/opts.c
92
gcc/opts.c
@ -29,6 +29,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
#include "options.h"
|
||||
#include "flags.h"
|
||||
#include "toplev.h"
|
||||
#include "params.h"
|
||||
|
||||
/* Value of the -G xx switch, and whether it was passed or not. */
|
||||
unsigned HOST_WIDE_INT g_switch_value;
|
||||
@ -40,8 +41,13 @@ bool exit_after_options;
|
||||
/* If -version. */
|
||||
bool version_flag;
|
||||
|
||||
/* Hack for cooperation between set_Wunused and set_Wextra. */
|
||||
static bool maybe_warn_unused_parameter;
|
||||
|
||||
static size_t find_opt (const char *, int);
|
||||
static int common_handle_option (size_t scode, const char *arg, int value);
|
||||
static void handle_param (const char *);
|
||||
static void set_Wextra (int);
|
||||
|
||||
/* Perform a binary search to find which option the command-line INPUT
|
||||
matches. Returns its index in the option array, and N_OPTS on
|
||||
@ -281,6 +287,10 @@ common_handle_option (size_t scode, const char *arg,
|
||||
exit_after_options = true;
|
||||
break;
|
||||
|
||||
case OPT__param:
|
||||
handle_param (arg);
|
||||
break;
|
||||
|
||||
case OPT__target_help:
|
||||
display_target_options ();
|
||||
exit_after_options = true;
|
||||
@ -296,6 +306,24 @@ common_handle_option (size_t scode, const char *arg,
|
||||
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_Wunused:
|
||||
set_Wunused (value);
|
||||
break;
|
||||
|
||||
case OPT_aux_info:
|
||||
case OPT_aux_info_:
|
||||
aux_info_file_name = arg;
|
||||
@ -323,6 +351,10 @@ common_handle_option (size_t scode, const char *arg,
|
||||
dump_base_name = arg;
|
||||
break;
|
||||
|
||||
case OPT_m:
|
||||
set_target_switch (arg);
|
||||
break;
|
||||
|
||||
case OPT_o:
|
||||
asm_file_name = arg;
|
||||
break;
|
||||
@ -354,3 +386,63 @@ common_handle_option (size_t scode, const char *arg,
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Handle --param NAME=VALUE. */
|
||||
static void
|
||||
handle_param (const char *carg)
|
||||
{
|
||||
char *equal, *arg;
|
||||
int value;
|
||||
|
||||
arg = xstrdup (carg);
|
||||
equal = strchr (arg, '=');
|
||||
if (!equal)
|
||||
error ("%s: --param arguments should be of the form NAME=VALUE", arg);
|
||||
else
|
||||
{
|
||||
value = integral_argument (equal + 1);
|
||||
if (value == -1)
|
||||
error ("invalid --param value `%s'", equal + 1);
|
||||
else
|
||||
{
|
||||
*equal = '\0';
|
||||
set_param_value (arg, value);
|
||||
}
|
||||
}
|
||||
|
||||
free (arg);
|
||||
}
|
||||
|
||||
/* Handle -W and -Wextra. */
|
||||
static void
|
||||
set_Wextra (int setting)
|
||||
{
|
||||
extra_warnings = setting;
|
||||
warn_unused_value = setting;
|
||||
warn_unused_parameter = (setting && maybe_warn_unused_parameter);
|
||||
|
||||
/* 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 (setting == 0)
|
||||
warn_uninitialized = 0;
|
||||
else if (warn_uninitialized != 1)
|
||||
warn_uninitialized = 2;
|
||||
}
|
||||
|
||||
/* Initialize unused warning flags. */
|
||||
void
|
||||
set_Wunused (int setting)
|
||||
{
|
||||
warn_unused_function = setting;
|
||||
warn_unused_label = setting;
|
||||
/* Unused function parameter warnings are reported when either
|
||||
``-Wextra -Wunused'' or ``-Wunused-parameter'' is specified.
|
||||
Thus, if -Wextra has already been seen, set warn_unused_parameter;
|
||||
otherwise set maybe_warn_extra_parameter, which will be picked up
|
||||
by set_Wextra. */
|
||||
maybe_warn_unused_parameter = setting;
|
||||
warn_unused_parameter = (setting && extra_warnings);
|
||||
warn_unused_variable = setting;
|
||||
warn_unused_value = setting;
|
||||
}
|
||||
|
115
gcc/toplev.c
115
gcc/toplev.c
@ -113,8 +113,6 @@ static int lang_dependent_init (const char *);
|
||||
static void init_asm_output (const char *);
|
||||
static void finalize (void);
|
||||
|
||||
static void set_target_switch (const char *);
|
||||
|
||||
static void crash_signal (int) ATTRIBUTE_NORETURN;
|
||||
static void setup_core_dumping (void);
|
||||
static void compile_file (void);
|
||||
@ -122,8 +120,7 @@ static void compile_file (void);
|
||||
static int decode_f_option (const char *);
|
||||
static int decode_W_option (const char *);
|
||||
static int decode_g_option (const char *);
|
||||
static unsigned int independent_decode_option (int, char **);
|
||||
static void set_Wextra (int);
|
||||
static unsigned int independent_decode_option (char **);
|
||||
|
||||
static int print_single_switch (FILE *, int, int, const char *,
|
||||
const char *, const char *,
|
||||
@ -1503,9 +1500,6 @@ int warn_unused_parameter;
|
||||
int warn_unused_variable;
|
||||
int warn_unused_value;
|
||||
|
||||
/* Used for cooperation between set_Wunused and set_Wextra. */
|
||||
static int maybe_warn_unused_parameter;
|
||||
|
||||
/* Nonzero to warn about code which is never reached. */
|
||||
|
||||
int warn_notreached;
|
||||
@ -1635,40 +1629,6 @@ static const lang_independent_options W_options[] =
|
||||
N_ ("Warn about code which might break the strict aliasing rules") }
|
||||
};
|
||||
|
||||
/* Initialize unused warning flags. */
|
||||
void
|
||||
set_Wunused (int setting)
|
||||
{
|
||||
warn_unused_function = setting;
|
||||
warn_unused_label = setting;
|
||||
/* Unused function parameter warnings are reported when either
|
||||
``-Wextra -Wunused'' or ``-Wunused-parameter'' is specified.
|
||||
Thus, if -Wextra has already been seen, set warn_unused_parameter;
|
||||
otherwise set maybe_warn_extra_parameter, which will be picked up
|
||||
by set_Wextra. */
|
||||
maybe_warn_unused_parameter = setting;
|
||||
warn_unused_parameter = (setting && extra_warnings);
|
||||
warn_unused_variable = setting;
|
||||
warn_unused_value = setting;
|
||||
}
|
||||
|
||||
/* Initialize more unused warning flags. */
|
||||
static void
|
||||
set_Wextra (int setting)
|
||||
{
|
||||
extra_warnings = setting;
|
||||
warn_unused_value = setting;
|
||||
warn_unused_parameter = (setting && maybe_warn_unused_parameter);
|
||||
|
||||
/* 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 (setting == 0)
|
||||
warn_uninitialized = 0;
|
||||
else if (warn_uninitialized != 1)
|
||||
warn_uninitialized = 2;
|
||||
}
|
||||
|
||||
/* The following routines are useful in setting all the flags that
|
||||
-ffast-math and -fno-fast-math imply. */
|
||||
|
||||
@ -4426,22 +4386,6 @@ decode_W_option (const char *arg)
|
||||
|
||||
warn_larger_than = larger_than_size != -1;
|
||||
}
|
||||
else if (!strcmp (arg, "unused"))
|
||||
{
|
||||
set_Wunused (1);
|
||||
}
|
||||
else if (!strcmp (arg, "no-unused"))
|
||||
{
|
||||
set_Wunused (0);
|
||||
}
|
||||
else if (!strcmp (arg, "extra"))
|
||||
{
|
||||
set_Wextra (1);
|
||||
}
|
||||
else if (!strcmp (arg, "no-extra"))
|
||||
{
|
||||
set_Wextra (0);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
@ -4578,7 +4522,7 @@ ignoring option `%s' due to invalid debug level specification",
|
||||
Return the number of strings consumed. */
|
||||
|
||||
static unsigned int
|
||||
independent_decode_option (int argc, char **argv)
|
||||
independent_decode_option (char **argv)
|
||||
{
|
||||
char *arg = argv[0];
|
||||
|
||||
@ -4587,53 +4531,11 @@ independent_decode_option (int argc, char **argv)
|
||||
|
||||
arg++;
|
||||
|
||||
/* Handle '--param <name>=<value>'. */
|
||||
if (strcmp (arg, "-param") == 0)
|
||||
{
|
||||
char *equal;
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
error ("-param option missing argument");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Get the '<name>=<value>' parameter. */
|
||||
arg = argv[1];
|
||||
/* Look for the `='. */
|
||||
equal = strchr (arg, '=');
|
||||
if (!equal)
|
||||
error ("invalid --param option: %s", arg);
|
||||
else
|
||||
{
|
||||
int val;
|
||||
|
||||
/* Zero out the `=' sign so that we get two separate strings. */
|
||||
*equal = '\0';
|
||||
/* Figure out what value is specified. */
|
||||
val = read_integral_parameter (equal + 1, NULL, INVALID_PARAM_VAL);
|
||||
if (val != INVALID_PARAM_VAL)
|
||||
set_param_value (arg, val);
|
||||
else
|
||||
error ("invalid parameter value `%s'", equal + 1);
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
switch (*arg)
|
||||
{
|
||||
default:
|
||||
return 0;
|
||||
|
||||
case 'O':
|
||||
/* Already been treated in main (). Do nothing. */
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
set_target_switch (arg + 1);
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
return decode_f_option (arg + 1);
|
||||
|
||||
@ -4641,21 +4543,14 @@ independent_decode_option (int argc, char **argv)
|
||||
return decode_g_option (arg + 1);
|
||||
|
||||
case 'W':
|
||||
/* For backward compatibility, -W is the same as -Wextra. */
|
||||
if (arg[1] == 0)
|
||||
set_Wextra (1);
|
||||
else
|
||||
return decode_W_option (arg + 1);
|
||||
break;
|
||||
return decode_W_option (arg + 1);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Decode -m switches. */
|
||||
/* Decode the switch -mNAME. */
|
||||
|
||||
static void
|
||||
void
|
||||
set_target_switch (const char *name)
|
||||
{
|
||||
size_t j;
|
||||
@ -5117,7 +5012,7 @@ parse_options_and_default_flags (int argc, char **argv)
|
||||
/* Now see if the option also has a language independent meaning.
|
||||
Some options are both language specific and language independent,
|
||||
eg --help. */
|
||||
indep_processed = independent_decode_option (argc - i, argv + i);
|
||||
indep_processed = independent_decode_option (argv + i);
|
||||
else
|
||||
{
|
||||
lang_processed = -lang_processed;
|
||||
|
@ -107,6 +107,7 @@ extern int target_flags_explicit;
|
||||
extern void display_help (void);
|
||||
extern void display_target_options (void);
|
||||
extern void print_version (FILE *, const char *);
|
||||
extern void set_target_switch (const char *);
|
||||
|
||||
/* The hashtable, so that the C front ends can pass it to cpplib. */
|
||||
extern struct ht *ident_hash;
|
||||
|
Loading…
Reference in New Issue
Block a user