From patchwork Fri Jan 28 10:10:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1585596 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=oE2bmOD2; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JlYDB3cqXz9sPC for ; Fri, 28 Jan 2022 21:12:24 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 67ADE3947C36 for ; Fri, 28 Jan 2022 10:12:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 67ADE3947C36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1643364741; bh=sbPbuPvYm7AZjiHaGzejRNANA0hHosFeb+6AFWqVCGk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=oE2bmOD2NmPF77uaJ+JT/NfK4lMbxY/A5hChjUKMvTopKOcww6+eGVRiW3xOPjP3p 4oC/h9/Q5r+UjUxdoemCuQn3do7dqn+8JZlHBvbuS3361U4I1lUqfFQVdRoYI1/cex 4ecoOq55bKexkztd3ZtQx6cF5l3VCp3EKzJ5gnh4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 6D3A23947C31 for ; Fri, 28 Jan 2022 10:10:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6D3A23947C31 Received: by mail-wm1-x32a.google.com with SMTP id q9-20020a7bce89000000b00349e697f2fbso7834289wmj.0 for ; Fri, 28 Jan 2022 02:10:57 -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:subject:date:message-id:mime-version :content-transfer-encoding; bh=sbPbuPvYm7AZjiHaGzejRNANA0hHosFeb+6AFWqVCGk=; b=7TwOo2axVliX3Mrch2+u9Wt2N7B3+4uA9O+vh2/api9TYRFpPSjsCN3YCBdB8pKh4k 9J48LsicAqQbzHkhBEGEo58EU+s4oS0jwl09+2c2SQN8L7PfdrF1RWHC+E3wADQosWKV Gp9gqs4ivTkIdqbjmVaD8jwKtDb2YFdegc7WEd3LgUbCCX9QWB9W7vjeOQsbUxNp9cOr Qs/tuwXacL/y3j/o9RfWuBkY4bo6Nn1LiYCMzp6Uj2zZYRawMyHTwOfLm9ACwDk26lNI Lo+3JTNhhVN95DV4tPPnimgFhLxusVlXcn1mGOLuA4VC2CKNIjyoBtrMoEcx9xsxMih2 RM0g== X-Gm-Message-State: AOAM530Sgm2OHCNFynW2M+XLdqn8znk8L7AjIhGGEV+RehK1lDRuFO5U 5P9hX1gOyHlwctvEjFoVKvuKvN0r2RZ0jQ== X-Google-Smtp-Source: ABdhPJxya+uqhmraTogYmZhpZ0t7GHSqPZ+anyoNarTuBGmMxE4OOlvtDjzjjk8ozTL9ft3hXHySNg== X-Received: by 2002:a05:600c:48a:: with SMTP id d10mr6823372wme.100.1643364656181; Fri, 28 Jan 2022 02:10:56 -0800 (PST) Received: from fomalhaut.localnet ([2a01:e0a:41b:84f0:cf71:f5e0:b050:bede]) by smtp.gmail.com with ESMTPSA id j4sm4899092wrq.81.2022.01.28.02.10.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 02:10:55 -0800 (PST) X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix PR ada/104258 Date: Fri, 28 Jan 2022 11:10:54 +0100 Message-ID: <4373989.LvFx2qVVIh@fomalhaut> MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Eric Botcazou via Gcc-patches From: Eric Botcazou Reply-To: Eric Botcazou Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This is a regression present on mainline and 11 branch: the new transformation applied during expansion by Narrow_Large_Operation would incorrectly perform name resolution for the operator again. Tested on x86_64-suse-linux, applied on mainline and 11 branch. 2022-01-28 Eric Botcazou PR ada/104258 * exp_ch4.adb (Narrow_Large_Operation): Also copy the entity, if any, when rewriting the operator node. 2022-01-28 Eric Botcazou * gnat.dg/generic_comp.adb: New test. diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index c31f5bb36ba..2506c67e936 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -14314,9 +14314,13 @@ package body Exp_Ch4 is return; end if; - -- Finally, rewrite the operation in the narrower type + -- Finally, rewrite the operation in the narrower type, but make sure + -- not to perform name resolution for the operator again. Nop := New_Op_Node (Kind, Sloc (N)); + if Nkind (N) in N_Has_Entity then + Set_Entity (Nop, Entity (N)); + end if; if Binary then Set_Left_Opnd (Nop, Convert_To (Ntyp, L));