From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 63BF33857C69 for ; Tue, 6 Oct 2020 13:20:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 63BF33857C69 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-99--dlS_5ZmPAKWMG1grd_h7Q-1; Tue, 06 Oct 2020 09:20:51 -0400 X-MC-Unique: -dlS_5ZmPAKWMG1grd_h7Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3480D8018A1; Tue, 6 Oct 2020 13:20:50 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-112-37.ams2.redhat.com [10.36.112.37]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C161E5579E; Tue, 6 Oct 2020 13:20:49 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id 096DKkt1002766; Tue, 6 Oct 2020 15:20:46 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 096DKjdo002765; Tue, 6 Oct 2020 15:20:45 +0200 Date: Tue, 6 Oct 2020 15:20:45 +0200 From: Jakub Jelinek To: Richard Biener , Andreas Schwab Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] options: Avoid unused variable mask warning [PR97305] Message-ID: <20201006132045.GD2176@tucnak> Reply-To: Jakub Jelinek References: <20200913082922.GF21814@tucnak> <20200928195000.GA6647@localhost.localdomain> <20200930093255.GK2176@tucnak> <20200930112144.GA97062@localhost.localdomain> <20200930113911.GM2176@tucnak> <20200930132408.GA146714@localhost.localdomain> <20201002084633.GV2176@tucnak> <87ft6uwjja.fsf@linux-m68k.org> <20201004191600.GH2176@tucnak> <875z7nn1op.fsf@igel.home> MIME-Version: 1.0 In-Reply-To: <875z7nn1op.fsf@igel.home> User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Oct 2020 13:20:54 -0000 Hi! On Tue, Oct 06, 2020 at 11:28:22AM +0200, Andreas Schwab wrote: > options-save.c: In function 'void cl_target_option_save(cl_target_option*, gcc_options*, gcc_options*)': > options-save.c:8526:26: error: unused variable 'mask' [-Werror=unused-variable] > 8526 | unsigned HOST_WIDE_INT mask = 0; > | ^~~~ > options-save.c: In function 'void cl_target_option_restore(gcc_options*, gcc_options*, cl_target_option*)': > options-save.c:8537:26: error: unused variable 'mask' [-Werror=unused-variable] > 8537 | unsigned HOST_WIDE_INT mask; > | ^~~~ Oops, missed that, sorry. The following patch should fix that, tested on x86_64-linux make options-save.c (same file as before) and -> ia64-linux cross make options-save.o (no warning anymore, just the unwanted declarations gone). Ok for trunk if it passes bootstrap/regtest? 2020-10-06 Jakub Jelinek PR bootstrap/97305 * optc-save-gen.awk: Don't declare mask variable if explicit_mask array is not present. --- gcc/optc-save-gen.awk.jj 2020-10-05 09:34:26.561874335 +0200 +++ gcc/optc-save-gen.awk 2020-10-06 14:44:04.679556591 +0200 @@ -597,11 +597,13 @@ for (i = 0; i < n_target_string; i++) { } print ""; -print " unsigned HOST_WIDE_INT mask = 0;"; j = 0; k = 0; for (i = 0; i < n_extra_target_vars; i++) { + if (j == 0 && k == 0) { + print " unsigned HOST_WIDE_INT mask = 0;"; + } print " if (opts_set->x_" extra_target_vars[i] ") mask |= HOST_WIDE_INT_1U << " j ";"; j++; if (j == 64) { @@ -617,6 +619,9 @@ for (i = 0; i < n_target_other; i++) { print " ptr->explicit_mask_" var_target_other[i] " = opts_set->x_" var_target_other[i] ";"; continue; } + if (j == 0 && k == 0) { + print " unsigned HOST_WIDE_INT mask = 0;"; + } print " if (opts_set->x_" var_target_other[i] ") mask |= HOST_WIDE_INT_1U << " j ";"; j++; if (j == 64) { @@ -628,6 +633,9 @@ for (i = 0; i < n_target_other; i++) { } for (i = 0; i < n_target_enum; i++) { + if (j == 0 && k == 0) { + print " unsigned HOST_WIDE_INT mask = 0;"; + } print " if (opts_set->x_" var_target_enum[i] ") mask |= HOST_WIDE_INT_1U << " j ";"; j++; if (j == 64) { @@ -643,6 +651,9 @@ for (i = 0; i < n_target_int; i++) { print " ptr->explicit_mask_" var_target_int[i] " = opts_set->x_" var_target_int[i] ";"; continue; } + if (j == 0 && k == 0) { + print " unsigned HOST_WIDE_INT mask = 0;"; + } print " if (opts_set->x_" var_target_int[i] ") mask |= HOST_WIDE_INT_1U << " j ";"; j++; if (j == 64) { @@ -654,6 +665,9 @@ for (i = 0; i < n_target_int; i++) { } for (i = 0; i < n_target_short; i++) { + if (j == 0 && k == 0) { + print " unsigned HOST_WIDE_INT mask = 0;"; + } print " if (opts_set->x_" var_target_short[i] ") mask |= HOST_WIDE_INT_1U << " j ";"; j++; if (j == 64) { @@ -665,6 +679,9 @@ for (i = 0; i < n_target_short; i++) { } for (i = 0; i < n_target_char; i++) { + if (j == 0 && k == 0) { + print " unsigned HOST_WIDE_INT mask = 0;"; + } print " if (opts_set->x_" var_target_char[i] ") mask |= HOST_WIDE_INT_1U << " j ";"; j++; if (j == 64) { @@ -676,6 +693,9 @@ for (i = 0; i < n_target_char; i++) { } for (i = 0; i < n_target_string; i++) { + if (j == 0 && k == 0) { + print " unsigned HOST_WIDE_INT mask = 0;"; + } print " if (opts_set->x_" var_target_string[i] ") mask |= HOST_WIDE_INT_1U << " j ";"; j++; if (j == 64) { @@ -732,7 +752,9 @@ for (i = 0; i < n_target_string; i++) { } print ""; -print " unsigned HOST_WIDE_INT mask;"; +if (has_target_explicit_mask) { + print " unsigned HOST_WIDE_INT mask;"; +} j = 64; k = 0; Jakub