From patchwork Fri Jun 21 08:58:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 1950642 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=Aby/vz5P; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W5BFP0X45z1ydW for ; Fri, 21 Jun 2024 19:02:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 355EC3899096 for ; Fri, 21 Jun 2024 09:02:15 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id EB6AB3896C23 for ; Fri, 21 Jun 2024 08:58:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EB6AB3896C23 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EB6AB3896C23 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::334 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960320; cv=none; b=YPwQIubBLGhGtHDE721ungXFoBVvuW5LNN1QZTSooIIOZl0yowoY24Eo7uBacYT3Vg7TMfZMBPfcsqlZZ2QXvI3tZXQaU0tabNPwpQ2XphrahlgPggV75H/nBgwFg7hzaSnv0aI/oWwTz8NAj9lhUSOhEexaRjDppoInHxPD634= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960320; c=relaxed/simple; bh=gNgajLoU8VGmhJ/ExEaiVAan8oje/DUy+VkAZnHyf8U=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XzxdX8ClgtvGQsigDQSVixh5O4Xg4dD9TltpU03Au7R8Bt1e0qItYT7Xu092Krvo0fcmWfhn2oNMBKJa0zTFejdO5WoY4+XBPkrMbbOwqphjEMtv2Xl8+yi87p+0n6hLYdHm+sNz656H12Baa651SjsoxVuaQrKiViBw1VZvuUU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-42172ed3597so10540845e9.0 for ; Fri, 21 Jun 2024 01:58:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960315; x=1719565115; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L/E8QanJK4eq/85xvkFY61yu0fTJ7Yq6PVPF3BntaU4=; b=Aby/vz5Pvpm7qMM92vwN9oCUQl+IB1SyEBn4VvyCO+vScctfwPRqnjSijfbW18tjpJ NOgNGGNIPy9mX0SpKzpFQpMkpFexat8E8BuyEPDdRp6pD08986hh8rMXcihkYT0sJBSW iHXYTnUwbBlwYRbAhNUNaxWo1cJyaeUH4jW9UFp2oLHrvBZVjYBgGWNcH/GT1aFvqw0R AE1suXYDGbfZUPwXu82ceOGXFOl2xiR0bDkOPazkWEFETwhWhBryojpuXqOl13GrOWEL 7Akee0xweXx5xRVpJoTcFcBcV7nxtADQardokug3Sr6eeCPbQXfcGL8OMzKVwrEKyT2e NcFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960315; x=1719565115; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L/E8QanJK4eq/85xvkFY61yu0fTJ7Yq6PVPF3BntaU4=; b=YV6XfehhWIa+nsc3S+TFNbAygduxAFA/J2Rm40Uxg4hEm0OxJ911TNczPBwFdPWERS 5IRusGTomkHPNQktDFCimkQZMm8KEoH5ptbnk0rrfb0E26Qo0m0GeKlA9PxNqwvBNBxk kZGN5/yWMg4QwhZ6KPAn3/NDhXAA0+j8FTwEmuJFS6u4QpL15AJhFNqDOQ0b7e/kTD4D riKJLzgnYM6L6dXRWpJ+2X6fc9XznUujmUxDRo9Hw3uoppxdY5QrzW8+UdrPPkAbeKb9 zP5ASzX2/FCQ8+QtvcJN8IE3IljeauMtNoTZF14sKQGecTGtkdh4V4wkQx7I+Hg+O/TE dw5Q== X-Gm-Message-State: AOJu0Yy8SBKEjkAXypzObHcxfyf+cyzavyzu1hhjbUkFy4gXyCuaylX2 eKomNoRq3ktnjmKDyW1fMUbMlLa16fdXUqULtoY9mJRrWyoYZ9WDz04eGElBSu2qoc7cf6YXl9U = X-Google-Smtp-Source: AGHT+IGcE2J+ajwe6qJyHE/+rPnDIdF+x07YIRJ5MPPeFgjPgd46//oKMWA6Limob+UcYEBkkgRWbg== X-Received: by 2002:a05:600c:4506:b0:422:291:6b3e with SMTP id 5b1f17b1804b1-4246f56d2b6mr102109525e9.1.1718960314690; Fri, 21 Jun 2024 01:58:34 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:a589:2704:bfe1:5d92]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4247d0c5485sm55322375e9.21.2024.06.21.01.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:34 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [COMMITTED 06/22] ada: Generic formal/actual matching -- misc cleanup Date: Fri, 21 Jun 2024 10:58:02 +0200 Message-ID: <20240621085819.2485987-6-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org From: Bob Duff The only substantive change is to remove Activation_Chain_Entity from N_Generic_Package_Declaration. The comment in sinfo.ads suggesting this change was written in 1993! Various pieces of missing documentation are added to Sinfo and Einfo. Also other minor cleanups. gcc/ada/ * gen_il-gen-gen_nodes.adb (N_Generic_Package_Declaration): Remove Activation_Chain_Entity. * sinfo.ads: Comment improvements. Add missing doc. Remove obsolete comment about Activation_Chain_Entity. * einfo.ads: Comment improvements. Add missing doc. * einfo-utils.adb (Base_Type): Add Assert (disabled for now). (Next_Index): Minor cleanup. * aspects.ads: Minor comment fix. * exp_ch6.adb: Likewise. * sem_ch3.adb: Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/aspects.ads | 2 +- gcc/ada/einfo-utils.adb | 29 ++++++++++++++++++++--------- gcc/ada/einfo.ads | 29 +++++++++++++++-------------- gcc/ada/exp_ch6.adb | 4 ++-- gcc/ada/gen_il-gen-gen_nodes.adb | 3 +-- gcc/ada/sem_ch3.adb | 4 ++-- gcc/ada/sinfo.ads | 32 ++++++++++++++++++-------------- 7 files changed, 59 insertions(+), 44 deletions(-) diff --git a/gcc/ada/aspects.ads b/gcc/ada/aspects.ads index 140fb7c8fe1..cf992a89038 100644 --- a/gcc/ada/aspects.ads +++ b/gcc/ada/aspects.ads @@ -1176,7 +1176,7 @@ package Aspects is Class_Present : Boolean := False; Or_Rep_Item : Boolean := False) return Node_Id; -- Find the aspect specification of aspect A (or A'Class if Class_Present) - -- associated with entity I. + -- associated with entity Id. -- If found, then return the aspect specification. -- If not found and Or_Rep_Item is true, then look for a representation -- item (as opposed to an N_Aspect_Specification node) which specifies diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb index 438868ac757..4c86ba1c3b1 100644 --- a/gcc/ada/einfo-utils.adb +++ b/gcc/ada/einfo-utils.adb @@ -664,12 +664,22 @@ package body Einfo.Utils is function Base_Type (Id : E) return E is begin - if Is_Base_Type (Id) then - return Id; - else - pragma Assert (Is_Type (Id)); - return Etype (Id); - end if; + return Result : E do + if Is_Base_Type (Id) then + Result := Id; + else + pragma Assert (Is_Type (Id)); + Result := Etype (Id); + if False then + pragma Assert (Is_Base_Type (Result)); + -- ???It seems like Base_Type should return a base type, + -- but this assertion is disabled because it is not always + -- true. Hence the need to say "Base_Type (Base_Type (...))" + -- in some cases; Base_Type is not idempotent as one might + -- expect. + end if; + end if; + end return; end Base_Type; ---------------------- @@ -2018,10 +2028,11 @@ package body Einfo.Utils is ---------------- function Next_Index (Id : N) return Node_Id is - begin pragma Assert (Nkind (Id) in N_Is_Index); - pragma Assert (No (Next (Id)) or else Nkind (Next (Id)) in N_Is_Index); - return Next (Id); + Result : constant Node_Id := Next (Id); + pragma Assert (No (Result) or else Nkind (Result) in N_Is_Index); + begin + return Result; end Next_Index; ------------------ diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index 8ee419b3e07..dd95ea051c1 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -1334,7 +1334,7 @@ package Einfo is -- First_Component (synthesized) -- Applies to incomplete, private, protected, record and task types. -- Returns the first component by following the chain of declared --- entities for the type a component is found (one with an Ekind of +-- entities for the type until a component is found (one with an Ekind of -- E_Component). The discriminants are skipped. If the record is null, -- then Empty is returned. @@ -1342,6 +1342,10 @@ package Einfo is -- Similar to First_Component, but discriminants are not skipped, so will -- find the first discriminant if discriminants are present. +-- First_Discriminant (synthesized) +-- Defined for types with discriminants or unknown discriminants. +-- Returns the first in the Next_Discriminant chain; see Sem_Aux. + -- First_Entity -- Defined in all entities that act as scopes to which a list of -- associated entities is attached, and also in all [sub]types. Some @@ -1375,12 +1379,11 @@ package Einfo is -- First_Index -- Defined in array types and subtypes. By introducing implicit subtypes -- for the index constraints, we have the same structure for constrained --- and unconstrained arrays, subtype marks and discrete ranges are --- both represented by a subtype. This function returns the tree node --- corresponding to an occurrence of the first index (NOT the entity for --- the type). Subsequent indices are obtained using Next_Index. Note that --- this field is defined for the case of string literal subtypes, but is --- always Empty. +-- and unconstrained arrays, subtype marks and discrete ranges are both +-- represented by a subtype. This function returns the N_Is_Index tree +-- node corresponding to the first index (not an entity). Subsequent +-- indices are obtained using Next_Index. Note that this field is defined +-- for the case of string literal subtypes, but is always Empty. -- First_Literal -- Defined in all enumeration types, including character and boolean @@ -3749,13 +3752,11 @@ package Einfo is -- all the extra formals (see description of Extra_Formal field) -- Next_Index (synthesized) --- Applies to array types and subtypes and to string types and --- subtypes. Yields the next index. The first index is obtained by --- using the First_Index attribute, and then subsequent indexes are --- obtained by applying Next_Index to the previous index. Empty is --- returned to indicate that there are no more indexes. Note that --- unlike most attributes in this package, Next_Index applies to --- nodes for the indexes, not to entities. +-- Applies to the N_Is_Index node returned by First_Index/Next_Index; +-- returns the next N_Is_Index node in the chain. Empty is returned to +-- indicate that there are no more indexes. Note that unlike most +-- attributes in this package, Next_Index applies to nodes for the +-- indexes, not to entities. -- Next_Inlined_Subprogram -- Defined in subprograms. Used to chain inlined subprograms used in diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index da19c031c3d..6d3d05fcf20 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -2939,8 +2939,8 @@ package body Exp_Ch6 is -- If the aspect is inherited, convert the pointer to the -- parent type that specifies the contract. -- If the original access_to_subprogram has defaults for - -- in_parameters, the call may include named associations, so - -- we create one for the pointer as well. + -- in-mode parameters, the call may include named associations, + -- so we create one for the pointer as well. if Is_Derived_Type (Ptr_Type) and then Ptr_Type /= Etype (Last_Formal (Wrapper)) diff --git a/gcc/ada/gen_il-gen-gen_nodes.adb b/gcc/ada/gen_il-gen-gen_nodes.adb index 580723666c5..b1ca6cf6c86 100644 --- a/gcc/ada/gen_il-gen-gen_nodes.adb +++ b/gcc/ada/gen_il-gen-gen_nodes.adb @@ -915,8 +915,7 @@ begin -- Gen_IL.Gen.Gen_Nodes Cc (N_Generic_Package_Declaration, N_Generic_Declaration, (Sy (Specification, Node_Id), Sy (Generic_Formal_Declarations, List_Id), - Sy (Aspect_Specifications, List_Id, Default_No_List), - Sm (Activation_Chain_Entity, Node_Id))); + Sy (Aspect_Specifications, List_Id, Default_No_List))); Cc (N_Generic_Subprogram_Declaration, N_Generic_Declaration, (Sy (Specification, Node_Id), diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index a1112d7b44a..fa13bd23ac7 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -1250,8 +1250,8 @@ package body Sem_Ch3 is -- to incomplete types declared in some enclosing scope, not to limited -- views from other packages. - -- Prior to Ada 2012, access to functions parameters must be of mode - -- 'in'. + -- Prior to Ada 2012, all parameters of an access-to-function type must + -- be of mode 'in'. if Present (Formals) then Formal := First_Formal (Desig_Type); diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index 599f4f63cce..3696ca4f7b4 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -2304,6 +2304,10 @@ package Sinfo is -- scope all use this field to reference the corresponding scope entity. -- See Einfo for further details. + -- Selector_Name + -- Present in N_Expanded_Name N_Selected_Component, + -- N_Generic_Association, and N_Parameter_Association nodes. + -- Shift_Count_OK -- A flag present in shift nodes to indicate that the shift count is -- known to be in range, i.e. is in the range from zero to word length @@ -7013,7 +7017,7 @@ package Sinfo is -- GENERIC_FORMAL_PART SUBPROGRAM_SPECIFICATION -- [ASPECT_SPECIFICATIONS]; - -- Note: Generic_Formal_Declarations can include pragmas + -- Note: Generic_Formal_Declarations can include pragmas and use clauses -- N_Generic_Subprogram_Declaration -- Sloc points to GENERIC @@ -7030,11 +7034,7 @@ package Sinfo is -- GENERIC_FORMAL_PART PACKAGE_SPECIFICATION -- [ASPECT_SPECIFICATIONS]; - -- Note: when we do generics right, the Activation_Chain_Entity entry - -- for this node can be removed (since the expander won't see generic - -- units any more)???. - - -- Note: Generic_Formal_Declarations can include pragmas + -- Note: Generic_Formal_Declarations can include pragmas and use clauses -- N_Generic_Package_Declaration -- Sloc points to GENERIC @@ -7042,7 +7042,6 @@ package Sinfo is -- Corresponding_Body -- Generic_Formal_Declarations from generic formal part -- Parent_Spec - -- Activation_Chain_Entity ------------------------------- -- 12.1 Generic Formal Part -- @@ -7143,16 +7142,19 @@ package Sinfo is -- Note: unlike the procedure call case, a generic association node -- is generated for every association, even if no formal parameter - -- selector name is present. In this case the parser will leave the - -- Selector_Name field set to Empty, to be filled in later by the - -- semantic pass. + -- selector name is present, in which case Selector_Name is Empty. -- In Ada 2005, a formal may be associated with a box, if the -- association is part of the list of actuals for a formal package. - -- If the association is given by OTHERS => <>, the association is + -- If the association is given by OTHERS => <>, the association is -- an N_Others_Choice (not an N_Generic_Association whose Selector_Name -- is an N_Others_Choice). + -- In source nodes, either Explicit_Generic_Actual_Parameter is present, + -- or Box_Present is True. However, Sem_Ch12 generates "dummy" nodes + -- with Explicit_Generic_Actual_Parameter = Empty and Box_Present = + -- False. + -- N_Generic_Association -- Sloc points to first token of generic association -- Selector_Name (set to Empty if no formal @@ -7382,13 +7384,15 @@ package Sinfo is -- Default_Name (set to Empty if no subprogram default) -- Box_Present -- Expression (set to Empty if no expression present) + -- If the default is "is null", then Null_Present is set + -- on the Specification of this node. -- Note: If no subprogram default is present, then Name is set -- to Empty, and Box_Present is False. - -- Note: The Expression field is only used for the GNAT extension - -- that allows a FORMAL_CONCRETE_SUBPROGRAM_DECLARATION to specify - -- an expression default for generic formal functions. + -- Note: The Expression field is for the GNAT extension that allows a + -- FORMAL_CONCRETE_SUBPROGRAM_DECLARATION to specify an expression + -- default for generic formal functions. -------------------------------------------------- -- 12.6 Formal Abstract Subprogram Declaration --