#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;
/* 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
exit_after_options = true;
break;
+ case OPT__param:
+ handle_param (arg);
+ break;
+
case OPT__target_help:
display_target_options ();
exit_after_options = true;
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;
dump_base_name = arg;
break;
+ case OPT_m:
+ set_target_switch (arg);
+ break;
+
case OPT_o:
asm_file_name = arg;
break;
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;
+}
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);
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 *,
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;
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. */
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;
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];
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);
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;
/* 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;