From patchwork Fri May 7 09:38:23 2021 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: 1475424 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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@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 ozlabs.org (Postfix) with ESMTPS id 4Fc54W6HvGz9t0G for ; Fri, 7 May 2021 19:39:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ECB603835418; Fri, 7 May 2021 09:38:31 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTP id BAC7A38930D3 for ; Fri, 7 May 2021 09:38:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BAC7A38930D3 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=derodat@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 4530F5635E; Fri, 7 May 2021 05:38:23 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id aLwgf7lGjOpm; Fri, 7 May 2021 05:38:23 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 33E5B5635D; Fri, 7 May 2021 05:38:23 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id 33057FA; Fri, 7 May 2021 05:38:23 -0400 (EDT) Date: Fri, 7 May 2021 05:38:23 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Subject: [Ada] Remove End_Interp_List from the overloaded resolution API Message-ID: <20210507093823.GA140655@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_ASCII_DIVIDERS, KAM_DMARC_STATUS, 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: , Cc: Piotr Trojanek Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Routine End_Interp_List was part of the API for overloaded resolution from the very beginning. However, it quickly become unnecessary, because both adding and removing interpretation maintains a No_Interp marker at the end of the interpretation list. The only effect of this routine was that it prevented duplicated interpretation entries from appearing on the interpretation list, but it was only because the explicit guard for preventing such duplicates was not always working. In particular, this guard didn't work when an overloaded expression of a generic unit parameter was first preanalyzed (when checking the legality of the instantiation) and then analyzed (when actually instantiating the generic unit). This patch fixes protection against duplicate entries on the lists with overloaded interpretations and removes the End_Interp_List routine. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch4.adb (Analyze_Call): Remove call to End_Interp_List. (Process_Overloaded_Indexed_Component): Remove call to End_Interp_List. * sem_util.adb (Insert_Explicit_Dereference): Remove call to End_Interp_List. * sem_type.ads (End_Interp_List): Remove. * sem_type.adb (Add_Entry): The guard against duplicate entries is now checked before other conditions, so that EXIT statements do not bypass this guard. (End_Interp_List): Remove. diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -1461,8 +1461,6 @@ package body Sem_Ch4 is else Remove_Abstract_Operations (N); end if; - - End_Interp_List; end if; -- Check the accessibility level for actuals for explicitly aliased @@ -2790,8 +2788,6 @@ package body Sem_Ch4 is Error_Msg_N ("no legal interpretation for indexed component", N); Set_Is_Overloaded (N, False); end if; - - End_Interp_List; end Process_Overloaded_Indexed_Component; -- Start of processing for Analyze_Indexed_Component_Form diff --git a/gcc/ada/sem_type.adb b/gcc/ada/sem_type.adb --- a/gcc/ada/sem_type.adb +++ b/gcc/ada/sem_type.adb @@ -239,6 +239,13 @@ package body Sem_Type is Get_First_Interp (N, I, It); while Present (It.Nam) loop + -- Avoid making duplicate entries in overloads + + if Name = It.Nam + and then Base_Type (It.Typ) = Base_Type (T) + then + return; + -- A user-defined subprogram hides another declared at an outer -- level, or one that is use-visible. So return if previous -- definition hides new one (which is either in an outer @@ -248,7 +255,7 @@ package body Sem_Type is -- If this is a universal operation, retain the operator in case -- preference rule applies. - if (((Ekind (Name) = E_Function or else Ekind (Name) = E_Procedure) + elsif ((Ekind (Name) in E_Function | E_Procedure and then Ekind (Name) = Ekind (It.Nam)) or else (Ekind (Name) = E_Operator and then Ekind (It.Nam) = E_Function)) @@ -292,13 +299,6 @@ package body Sem_Type is return; end if; - -- Avoid making duplicate entries in overloads - - elsif Name = It.Nam - and then Base_Type (It.Typ) = Base_Type (T) - then - return; - -- Otherwise keep going else @@ -2227,16 +2227,6 @@ package body Sem_Type is end if; end Disambiguate; - --------------------- - -- End_Interp_List -- - --------------------- - - procedure End_Interp_List is - begin - All_Interp.Table (All_Interp.Last) := No_Interp; - All_Interp.Increment_Last; - end End_Interp_List; - ------------------------- -- Entity_Matches_Spec -- ------------------------- diff --git a/gcc/ada/sem_type.ads b/gcc/ada/sem_type.ads --- a/gcc/ada/sem_type.ads +++ b/gcc/ada/sem_type.ads @@ -130,9 +130,6 @@ package Sem_Type is -- always Boolean, and we use Opnd_Type, which is a candidate type for one -- of the operands of N, to check visibility. - procedure End_Interp_List; - -- End the list of interpretations of current node - procedure Get_First_Interp (N : Node_Id; I : out Interp_Index; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -15044,8 +15044,6 @@ package body Sem_Util is Get_Next_Interp (I, It); end loop; - End_Interp_List; - else -- Prefix is unambiguous: mark the original prefix (which might -- Come_From_Source) as a reference, since the new (relocated) one