From patchwork Thu May 19 14:16:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 54221 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C546A3839425 for ; Thu, 19 May 2022 14:32:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C546A3839425 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652970741; bh=G4/hAQAGSYEQFq5yxJ5HxE8vWRkzQ8AY5N9GIAJnOck=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=UdxOIKeBRJCVt6C2CfYxAe9obdu/ZbrZpbiKB4THAoNS74og9mp3Qv1eyIQG66Ea3 feuh+AaXTy0hVzlNzHBL75thwzA/0EpWMZXBN25ZRR7IyGYDEdDT89S7c6OLYjXNP/ OanuPIBc/dGAXWAIJQpiI7niPGRIaCHEEYMMEoGA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 048EE383D83B for ; Thu, 19 May 2022 14:16:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 048EE383D83B Received: by mail-wr1-x42b.google.com with SMTP id f2so7424819wrc.0 for ; Thu, 19 May 2022 07:16:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=G4/hAQAGSYEQFq5yxJ5HxE8vWRkzQ8AY5N9GIAJnOck=; b=aWffVyy2GTExn3d57VVHQF96pVCzQYDko8c/sawdy88ZpJSafoffDgtLMNltQLxSIB wlh1p0MbrQnZTVSK7GoiP8wGyI4o7gJiNgK6BGTuoGvzxdCoqSmFshYdCsTs+mFioPlr we34/tZT5pPDEKCbdVPdNAOz3R9AhHE8Qn1FK6vM27lCYvrx+K5s71S0bpQHH3qIC7Qg Ul9/DPEbGa/FdLGqHM5cQZ1Tu6IIGY60/er2nbIrPrbRhOrBiXpl8Zv3tdHRHa9/B8BL DivsAkA7KLmoEgilUEOi+4IdkgGDDghlMpFrjKpZZ4dzYEKcK9vJVHbVk7iKE76NuxWy zaHQ== X-Gm-Message-State: AOAM53392XHXE/ibZ0C+jnBaRW1f5id9P+kBJSpveERe8O4arVT4G3XB +PKm8bMYcpgP84Grc/2dJwq6OUMbJOnDLQ== X-Google-Smtp-Source: ABdhPJxWQxzhnLVDf4P8rY+wYEmTbpfdTpyquRgpn9hR8blBW6Nr32aYNXgshEY1ehoBVZk/EdAYnw== X-Received: by 2002:a5d:6550:0:b0:20e:6984:31d0 with SMTP id z16-20020a5d6550000000b0020e698431d0mr2936711wrv.257.1652969773844; Thu, 19 May 2022 07:16:13 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id x26-20020adfae1a000000b0020c5253d8fdsm4874010wrc.73.2022.05.19.07.16.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 May 2022 07:16:13 -0700 (PDT) Date: Thu, 19 May 2022 14:16:12 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Preserve and reuse original type in Narrow_Large_Operation Message-ID: <20220519141612.GA3723350@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Eric Botcazou Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Instead of using that of Original_Node (N) after rewriting, which does not work if N had previously been rewritten. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Narrow_Large_Operation): Preserve and reuse Etype. diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -14108,6 +14108,7 @@ package body Exp_Ch4 is procedure Narrow_Large_Operation (N : Node_Id) is Kind : constant Node_Kind := Nkind (N); + Otyp : constant Entity_Id := Etype (N); In_Rng : constant Boolean := Kind = N_In; Binary : constant Boolean := Kind in N_Binary_Op or else In_Rng; Compar : constant Boolean := Kind in N_Op_Compare or else In_Rng; @@ -14262,8 +14263,7 @@ package body Exp_Ch4 is -- Analyze it with the comparison type and checks suppressed since -- the conversions of the operands cannot overflow. - Analyze_And_Resolve - (N, Etype (Original_Node (N)), Suppress => Overflow_Check); + Analyze_And_Resolve (N, Otyp, Suppress => Overflow_Check); else -- Analyze it with the narrower type and checks suppressed, but only