public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix some narrowing conversion issues
Date: Tue, 27 Jun 2017 05:50:00 -0000	[thread overview]
Message-ID: <20170627054824.GN2123@tucnak> (raw)

Hi!

We build gcc with -Wno-narrowing, for some reason I ended up with old
Makefile without that and discovered a couple of -Wnarrowing errors.

This patch fixes them.  Bootstrapped/regtested on x86_64-linux (i686-linux
fails to bootstrap with/without this patch), ok for trunk?

2017-06-27  Jakub Jelinek  <jakub@redhat.com>

	* predict.c (test_prediction_value_range): Use -1U instead of -1
	to avoid narrowing conversion warning.
	* dumpfile.c (dump_options): Wrap all value into dump_flags_t cast
	to avoid narrowing conversion warning.
	* opt-functions.awk (var_ref): Return (unsigned short) -1 instead of
	-1.
	* optc-gen.awk (END): Expect (unsigned short) -1 instead of -1.

--- gcc/predict.c.jj	2017-06-21 16:53:37.000000000 +0200
+++ gcc/predict.c	2017-06-26 18:39:33.640190953 +0200
@@ -4031,7 +4031,7 @@ test_prediction_value_range ()
 {
   branch_predictor predictors[] = {
 #include "predict.def"
-    {NULL, -1}
+    {NULL, -1U}
   };
 
   for (unsigned i = 0; predictors[i].name != NULL; i++)
--- gcc/dumpfile.c.jj	2017-06-19 08:27:22.000000000 +0200
+++ gcc/dumpfile.c	2017-06-26 18:38:44.383762664 +0200
@@ -110,9 +110,9 @@ static const struct dump_option_value_in
   {"missed", MSG_MISSED_OPTIMIZATION},
   {"note", MSG_NOTE},
   {"optall", MSG_ALL},
-  {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_GRAPH | TDF_STMTADDR
-	    | TDF_RHS_ONLY | TDF_NOUID | TDF_ENUMERATE_LOCALS | TDF_SCEV
-	    | TDF_GIMPLE)},
+  {"all", dump_flags_t (~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_GRAPH
+			| TDF_STMTADDR | TDF_RHS_ONLY | TDF_NOUID
+			| TDF_ENUMERATE_LOCALS | TDF_SCEV | TDF_GIMPLE))},
   {NULL, 0}
 };
 
--- gcc/opt-functions.awk.jj	2017-01-08 17:41:19.000000000 +0100
+++ gcc/opt-functions.awk	2017-06-26 18:54:15.174940306 +0200
@@ -275,7 +275,7 @@ function var_ref(name, flags)
 		return "offsetof (struct gcc_options, x_target_flags)"
 	if (opt_args("InverseMask", flags) != "")
 		return "offsetof (struct gcc_options, x_target_flags)"
-	return "-1"
+	return "(unsigned short) -1"
 }
 
 # Given the option called NAME return a sanitized version of its name.
--- gcc/optc-gen.awk.jj	2017-02-25 00:15:02.000000000 +0100
+++ gcc/optc-gen.awk	2017-06-26 18:55:41.613928361 +0200
@@ -336,7 +336,7 @@ for (i = 0; i < n_opts; i++) {
 		alias_posarg = nth_arg(1, alias_arg)
 		alias_negarg = nth_arg(2, alias_arg)
 
-		if (var_ref(opts[i], flags[i]) != "-1")
+		if (var_ref(opts[i], flags[i]) != "(unsigned short) -1")
 			print "#error Alias setting variable"
 
 		if (alias_posarg != "" && alias_negarg == "") {

	Jakub

             reply	other threads:[~2017-06-27  5:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27  5:50 Jakub Jelinek [this message]
2017-06-27  8:50 ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170627054824.GN2123@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).