diff mbox series

[pushed] opts: fix narrowing warning

Message ID 20241111223027.34241-1-jason@redhat.com
State New
Headers show
Series [pushed] opts: fix narrowing warning | expand

Commit Message

Jason Merrill Nov. 11, 2024, 10:29 p.m. UTC
Tested x86_64-pc-linux-gnu, applying as obvious.

-- 8< --

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.
---
 gcc/opts.h         | 4 ++--
 gcc/opts-common.cc | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)


base-commit: 416a8b375589d4c2891b437d0991296ef32bde98
diff mbox series

Patch

diff --git a/gcc/opts.h b/gcc/opts.h
index 3fc57773f4e..25dd42b0796 100644
--- a/gcc/opts.h
+++ b/gcc/opts.h
@@ -300,7 +300,7 @@  struct cl_deferred_option
      options.  */
   size_t opt_index;
   const char *arg;
-  int value;
+  HOST_WIDE_INT value;
 };
 
 /* Structure describing a single option-handling callback.  */
@@ -398,7 +398,7 @@  extern bool get_option_state (struct gcc_options *, int,
 			      struct cl_option_state *);
 extern void set_option (struct gcc_options *opts,
 			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,
 			HOST_WIDE_INT = 0);
 extern void *option_flag_var (int opt_index, struct gcc_options *opts);
diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc
index ac2e77b1659..6ab26051297 100644
--- a/gcc/opts-common.cc
+++ b/gcc/opts-common.cc
@@ -1656,8 +1656,8 @@  read_cmdline_option (struct gcc_options *opts,
 
 void
 set_option (struct gcc_options *opts, struct gcc_options *opts_set,
-	    int opt_index, HOST_WIDE_INT value, const char *arg, int kind,
-	    location_t loc, diagnostic_context *dc,
+	    size_t opt_index, HOST_WIDE_INT value, const char *arg,
+	    int kind, location_t loc, diagnostic_context *dc,
 	    HOST_WIDE_INT mask /* = 0 */)
 {
   const struct cl_option *option = &cl_options[opt_index];