From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Y6p5NPKAjmHyZQAAWB0awg (envelope-from ) for ; Fri, 12 Nov 2021 09:57:54 -0500 Received: by simark.ca (Postfix, from userid 112) id C59B01F0C1; Fri, 12 Nov 2021 09:57:54 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 40A341ECEB for ; Fri, 12 Nov 2021 09:57:54 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9839E3858022 for ; Fri, 12 Nov 2021 14:57:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9839E3858022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1636729073; bh=uf4EPdFYJEz8ZBifqqzXWiSHiVznEPB9qWuCidLN6+w=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=p2koLieIZQ2mZJf/CW9wIv0n0lvIDvJ683HjonMEtYR4dYz4REY5EYSP9SqGL00e2 84LlImOgSPeOOJcgUCXah6fUTtbQ+rRqjk5fvbwzUTddrF+NIgjO7e7AB+oLEJs+Iz K3rAvhwR4NjzkoE0C600wQREH88xZ+y5KO5dmp+c= Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by sourceware.org (Postfix) with ESMTPS id E54CA3858402 for ; Fri, 12 Nov 2021 14:57:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E54CA3858402 Received: by mail-qk1-x72b.google.com with SMTP id de30so9362899qkb.0 for ; Fri, 12 Nov 2021 06:57:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uf4EPdFYJEz8ZBifqqzXWiSHiVznEPB9qWuCidLN6+w=; b=1YjxgufqYV8W6nHJSMSX8JZr67+m09uMPeNsO0G8QsEcWZx+yOffUCrxGoh785hgYJ fi9TFr4629RbwhJFafeGDKpGvuRusasfCCC94CjedbhmvMKLZnQq7jZKKbAJIpGxoIKR APW/HCht/SumYqcRe0ycJdEB4iklYn1aGk5HJa3Ovy8+gTOmvZ01mBpQJ9lHuNS58+vW piaf+K84h/TSdZemFBNGa090ILyw68fNYtJUjWx6qZgkwgGzmFWM+X94dVwPFJyDnDqv DwtZYgxtQUuPNm4pGwwk9nAcz7znDZHlIUSZuAfAcJQc6wfvSUgS9QtP8n1zqrEwYL6y 72bg== X-Gm-Message-State: AOAM531k3AHe29oUPP6HH030L/IYPgkyM8fBWsjFbgSTv6q9mh+bHKhQ Z2GyNWNVKjJKcXch+qA06yky56WzDOeRAQ== X-Google-Smtp-Source: ABdhPJzhE7jaSdUFJza7oHqbG+qv19T/5Sh9YhLfNmjf8Tr68GJD1cedEU2vQQ5Q2qoRQ0lLBsdvww== X-Received: by 2002:a05:620a:2153:: with SMTP id m19mr2783370qkm.77.1636729055541; Fri, 12 Nov 2021 06:57:35 -0800 (PST) Received: from localhost.localdomain ([2804:7f0:4841:487c:58e2:edbd:1f61:6a61]) by smtp.gmail.com with ESMTPSA id g21sm1785092qtb.62.2021.11.12.06.57.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Nov 2021 06:57:35 -0800 (PST) To: gdb-patches@sourceware.org Subject: [PATCH] Fix SH sim build failures due to -Werror with GCC 7.5.x. Date: Fri, 12 Nov 2021 11:57:27 -0300 Message-Id: <20211112145727.1855584-1-luis.machado@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Luis Machado via Gdb-patches Reply-To: Luis Machado Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Adjust the statements to be mindful of signed overflows and initialize the res variable. This fixes the strict-overflow and maybe-uninitialized warnings seen below: binutils-gdb/sim/sh/interp.c: In function "ppi_insn": ./ppi.c:875:21: error: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Werror=strict-overflow] carry = res < Sy; ~~~~^~~~ ./ppi.c:849:21: error: assuming signed overflow does not occur when assuming that (X - c) > X is always false [-Werror=strict-overflow] carry = res > Sy; ~~~~^~~~ ./ppi.c:823:21: error: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Werror=strict-overflow] carry = res < Sx; ~~~~^~~~ ./ppi.c:797:21: error: assuming signed overflow does not occur when assuming that (X - c) > X is always false [-Werror=strict-overflow] carry = res > Sx; ~~~~^~~~ binutils-gdb-arm64-bionic/sim/../../../repos/binutils-gdb/sim/sh/interp.c: In function "sim_resume": ./ppi.c:1178:28: warning: "res" may be used uninitialized in this function [-Wmaybe-uninitialized] MACL = DSP_R (z) = res; ./ppi.c:44:7: note: "res" was declared here int res, res_grd; ^~~ --- sim/sh/gencode.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sim/sh/gencode.c b/sim/sh/gencode.c index 80eecfdf1d3..80cf573de0c 100644 --- a/sim/sh/gencode.c +++ b/sim/sh/gencode.c @@ -2266,7 +2266,7 @@ op ppi_tab[] = "int Sx_grd = GET_DSP_GRD (x);", "", "res = Sx - 0x10000;", - "carry = res > Sx;", + "carry = (Sx < 0 && Sx < INT_MIN + 0x10000);", "res_grd = Sx_grd - carry;", "COMPUTE_OVERFLOW;", "ADD_SUB_GE;", @@ -2277,7 +2277,7 @@ op ppi_tab[] = "int Sx_grd = GET_DSP_GRD (x);", "", "res = Sx + 0x10000;", - "carry = res < Sx;", + "carry = (Sx > 0 && Sx > INT_MAX - 0x10000);", "res_grd = Sx_grd + carry;", "COMPUTE_OVERFLOW;", "ADD_SUB_GE;", @@ -2288,7 +2288,7 @@ op ppi_tab[] = "int Sy_grd = SIGN32 (Sy);", "", "res = Sy - 0x10000;", - "carry = res > Sy;", + "carry = (Sy < 0 && Sy < INT_MIN + 0x10000);", "res_grd = Sy_grd - carry;", "COMPUTE_OVERFLOW;", "ADD_SUB_GE;", @@ -2299,7 +2299,7 @@ op ppi_tab[] = "int Sy_grd = SIGN32 (Sy);", "", "res = Sy + 0x10000;", - "carry = res < Sy;", + "carry = (Sy > 0 && Sy > INT_MAX - 0x10000);", "res_grd = Sy_grd + carry;", "COMPUTE_OVERFLOW;", "ADD_SUB_GE;", @@ -3257,7 +3257,7 @@ ppi_gensim (void) printf (" static char const u_tab[] = { 8, 10, 7, 5};\n"); printf ("\n"); printf (" int z;\n"); - printf (" int res, res_grd;\n"); + printf (" int res = 0, res_grd;\n"); printf (" int carry, overflow, greater_equal;\n"); printf ("\n"); printf (" switch (ppi_table[iword >> 4]) {\n"); -- 2.25.1