opts: fix narrowing warning

The init-list initialization of cl_deferred_option p had a couple of
narrowing warnings: first of opt_index from int to size_t and then of value
from HOST_WIDE_INT to int.  Fixed by making the types more consistent.

gcc/ChangeLog:

	* opts.h (cl_deferred_option::value): Change to HOST_WIDE_INT.
	(set_option): Change opt_index parm to size_t.
	* opts-common.cc (set_option): Likewise.
This commit is contained in:
Jason Merrill 2024-11-10 21:42:48 -05:00
parent f32e733987
commit e3de2962cb
2 changed files with 4 additions and 4 deletions

View File

@ -1656,8 +1656,8 @@ read_cmdline_option (struct gcc_options *opts,
void void
set_option (struct gcc_options *opts, struct gcc_options *opts_set, set_option (struct gcc_options *opts, struct gcc_options *opts_set,
int opt_index, HOST_WIDE_INT value, const char *arg, int kind, size_t opt_index, HOST_WIDE_INT value, const char *arg,
location_t loc, diagnostic_context *dc, int kind, location_t loc, diagnostic_context *dc,
HOST_WIDE_INT mask /* = 0 */) HOST_WIDE_INT mask /* = 0 */)
{ {
const struct cl_option *option = &cl_options[opt_index]; const struct cl_option *option = &cl_options[opt_index];

View File

@ -300,7 +300,7 @@ struct cl_deferred_option
options. */ options. */
size_t opt_index; size_t opt_index;
const char *arg; const char *arg;
int value; HOST_WIDE_INT value;
}; };
/* Structure describing a single option-handling callback. */ /* Structure describing a single option-handling callback. */
@ -398,7 +398,7 @@ extern bool get_option_state (struct gcc_options *, int,
struct cl_option_state *); struct cl_option_state *);
extern void set_option (struct gcc_options *opts, extern void set_option (struct gcc_options *opts,
struct gcc_options *opts_set, struct gcc_options *opts_set,
int opt_index, HOST_WIDE_INT value, const char *arg, size_t opt_index, HOST_WIDE_INT value, const char *arg,
int kind, location_t loc, diagnostic_context *dc, int kind, location_t loc, diagnostic_context *dc,
HOST_WIDE_INT = 0); HOST_WIDE_INT = 0);
extern void *option_flag_var (int opt_index, struct gcc_options *opts); extern void *option_flag_var (int opt_index, struct gcc_options *opts);