From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Preserve and reuse original type in Narrow_Large_Operation Message-ID: <20220519141612.GA3723350@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MGYHOYXEY6WxJCY8" 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-List-Received-Date: Thu, 19 May 2022 14:16:16 -0000 --MGYHOYXEY6WxJCY8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --MGYHOYXEY6WxJCY8 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" 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 --MGYHOYXEY6WxJCY8--