From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 89079 invoked by alias); 27 Jun 2017 08:50:32 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 89062 invoked by uid 89); 27 Jun 2017 08:50:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-ot0-f195.google.com Received: from mail-ot0-f195.google.com (HELO mail-ot0-f195.google.com) (74.125.82.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 27 Jun 2017 08:50:30 +0000 Received: by mail-ot0-f195.google.com with SMTP id z48so2321382otz.2 for ; Tue, 27 Jun 2017 01:50:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=cc4t0SQjEAgbGMySbOkFJC/L35dQE0Rs/NkqShUXkJw=; b=M4b0b2nAALjhEKL/U0beuacSaU7pKfjfIQ1bs80/GVz7w5LYP51sJ6zDNBNF9UBLQ9 tvSwJjNfio0nrTlXREmLUaam/KczKAN3/c5yenNOvZ8HSIO05xtKMgMSi5R6/N9NGiBB C+t2lrgKvhEMCIAEm4r371C8ixIspk6TXxwfqXejOLupt38wWVn4oZi9DMKBHg07xqig WM6T7ZudQ7wvLm3ZyiCQORkGR5xnLREdaX+gbnUaeJ1zmHPbSC16Uebbk2eQQooC3yxY TPvjWPFWK6YqDAUrWa7Z4YkNryBR6fca7U/lgG9cbpjEelzNvjxzU7oP6P/ZIfOr/re3 pxng== X-Gm-Message-State: AKS2vOx40V9ESEo7i9EyQIpHFFOkWGRaKq2x0BHfzwHyz7khr9Vh9CXg J2/MMB2H1g86LWuTWsYi9qU/Sa46LA== X-Received: by 10.157.10.161 with SMTP id 30mr3173870otq.105.1498553428665; Tue, 27 Jun 2017 01:50:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.37.66 with HTTP; Tue, 27 Jun 2017 01:50:28 -0700 (PDT) In-Reply-To: <20170627054824.GN2123@tucnak> References: <20170627054824.GN2123@tucnak> From: Richard Biener Date: Tue, 27 Jun 2017 08:50:00 -0000 Message-ID: Subject: Re: [PATCH] Fix some narrowing conversion issues To: Jakub Jelinek Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg01987.txt.bz2 On Tue, Jun 27, 2017 at 7:48 AM, Jakub Jelinek wrote: > 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? Ok. > 2017-06-27 Jakub Jelinek > > * 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