From patchwork Mon Aug 29 10:25:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 112014 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 9A03CB6F8C for ; Mon, 29 Aug 2011 20:25:52 +1000 (EST) Received: (qmail 14751 invoked by alias); 29 Aug 2011 10:25:49 -0000 Received: (qmail 14675 invoked by uid 22791); 29 Aug 2011 10:25:46 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 29 Aug 2011 10:25:30 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 638582BAECD; Mon, 29 Aug 2011 06:25:29 -0400 (EDT) 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 yRoo9g7eZ3KL; Mon, 29 Aug 2011 06:25:29 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 50D5C2BAE40; Mon, 29 Aug 2011 06:25:29 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 4F5913FEE8; Mon, 29 Aug 2011 06:25:29 -0400 (EDT) Date: Mon, 29 Aug 2011 06:25:29 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Matthew Heaney Subject: [Ada] Remove superfluous Container parameter Message-ID: <20110829102529.GA12464@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org The operations Find_In_Subtree and Ancestor_Find had a Container parameter as part of the signature (it was included in AI05-0136 by mistake), but that parameter is not necessary, and has therefore been removed. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-29 Matthew Heaney * a-comutr.ads, a-comutr.adb, a-cimutr.ads, a-cimutr.adb, a-cbmutr.ads, a-cbmutr.adb (Find_In_Subtree): Remove superfluous Container parameter. (Ancestor_Find): ditto. Index: a-cimutr.adb =================================================================== --- a-cimutr.adb (revision 178184) +++ a-cimutr.adb (working copy) @@ -164,22 +164,22 @@ ------------------- function Ancestor_Find - (Container : Tree; - Item : Element_Type; - Position : Cursor) return Cursor + (Position : Cursor; + Item : Element_Type) return Cursor is - R : constant Tree_Node_Access := Root_Node (Container); - N : Tree_Node_Access; + R, N : Tree_Node_Access; begin if Position = No_Element then raise Constraint_Error with "Position cursor has no element"; end if; - if Position.Container /= Container'Unrestricted_Access then - raise Program_Error with "Position cursor not in container"; - end if; + -- Commented-out pending ARG ruling. ??? + -- if Position.Container /= Container'Unrestricted_Access then + -- raise Program_Error with "Position cursor not in container"; + -- end if; + -- AI-0136 says to raise PE if Position equals the root node. This does -- not seem correct, as this value is just the limiting condition of the -- search. For now we omit this check pending a ruling from the ARG.??? @@ -188,10 +188,11 @@ -- raise Program_Error with "Position cursor designates root"; -- end if; + R := Root_Node (Position.Container.all); N := Position.Node; while N /= R loop if N.Element.all = Item then - return Cursor'(Container'Unrestricted_Access, N); + return Cursor'(Position.Container, N); end if; N := N.Parent; @@ -974,9 +975,8 @@ --------------------- function Find_In_Subtree - (Container : Tree; - Item : Element_Type; - Position : Cursor) return Cursor + (Position : Cursor; + Item : Element_Type) return Cursor is Result : Tree_Node_Access; @@ -985,10 +985,12 @@ raise Constraint_Error with "Position cursor has no element"; end if; - if Position.Container /= Container'Unrestricted_Access then - raise Program_Error with "Position cursor not in container"; - end if; + -- Commented-out pending ruling from ARG. ??? + -- if Position.Container /= Container'Unrestricted_Access then + -- raise Program_Error with "Position cursor not in container"; + -- end if; + if Is_Root (Position) then Result := Find_In_Children (Position.Node, Item); @@ -1000,7 +1002,7 @@ return No_Element; end if; - return Cursor'(Container'Unrestricted_Access, Result); + return Cursor'(Position.Container, Result); end Find_In_Subtree; function Find_In_Subtree Index: a-cimutr.ads =================================================================== --- a-cimutr.ads (revision 178155) +++ a-cimutr.ads (working copy) @@ -113,15 +113,37 @@ (Container : Tree; Item : Element_Type) return Cursor; + -- This version of the AI: + -- 10-06-02 AI05-0136-1/07 + -- declares Find_In_Subtree this way: + -- + -- function Find_In_Subtree + -- (Container : Tree; + -- Item : Element_Type; + -- Position : Cursor) return Cursor; + -- + -- It seems that the Container parameter is there by mistake, but we need + -- an official ruling from the ARG. ??? + function Find_In_Subtree - (Container : Tree; - Item : Element_Type; - Position : Cursor) return Cursor; + (Position : Cursor; + Item : Element_Type) return Cursor; + -- This version of the AI: + -- 10-06-02 AI05-0136-1/07 + -- declares Ancestor_Find this way: + -- + -- function Ancestor_Find + -- (Container : Tree; + -- Item : Element_Type; + -- Position : Cursor) return Cursor; + -- + -- It seems that the Container parameter is there by mistake, but we need + -- an official ruling from the ARG. ??? + function Ancestor_Find - (Container : Tree; - Item : Element_Type; - Position : Cursor) return Cursor; + (Position : Cursor; + Item : Element_Type) return Cursor; function Contains (Container : Tree; Index: a-comutr.adb =================================================================== --- a-comutr.adb (revision 178184) +++ a-comutr.adb (working copy) @@ -163,22 +163,22 @@ ------------------- function Ancestor_Find - (Container : Tree; - Item : Element_Type; - Position : Cursor) return Cursor + (Position : Cursor; + Item : Element_Type) return Cursor is - R : constant Tree_Node_Access := Root_Node (Container); - N : Tree_Node_Access; + R, N : Tree_Node_Access; begin if Position = No_Element then raise Constraint_Error with "Position cursor has no element"; end if; - if Position.Container /= Container'Unrestricted_Access then - raise Program_Error with "Position cursor not in container"; - end if; + -- Commented-out pending official ruling from ARG. ??? + -- if Position.Container /= Container'Unrestricted_Access then + -- raise Program_Error with "Position cursor not in container"; + -- end if; + -- AI-0136 says to raise PE if Position equals the root node. This does -- not seem correct, as this value is just the limiting condition of the -- search. For now we omit this check, pending a ruling from the ARG.??? @@ -187,10 +187,11 @@ -- raise Program_Error with "Position cursor designates root"; -- end if; + R := Root_Node (Position.Container.all); N := Position.Node; while N /= R loop if N.Element = Item then - return Cursor'(Container'Unrestricted_Access, N); + return Cursor'(Position.Container, N); end if; N := N.Parent; @@ -950,9 +951,8 @@ --------------------- function Find_In_Subtree - (Container : Tree; - Item : Element_Type; - Position : Cursor) return Cursor + (Position : Cursor; + Item : Element_Type) return Cursor is Result : Tree_Node_Access; @@ -961,10 +961,12 @@ raise Constraint_Error with "Position cursor has no element"; end if; - if Position.Container /= Container'Unrestricted_Access then - raise Program_Error with "Position cursor not in container"; - end if; + -- Commented out pending official ruling by ARG. ??? + -- if Position.Container /= Container'Unrestricted_Access then + -- raise Program_Error with "Position cursor not in container"; + -- end if; + if Is_Root (Position) then Result := Find_In_Children (Position.Node, Item); @@ -976,7 +978,7 @@ return No_Element; end if; - return Cursor'(Container'Unrestricted_Access, Result); + return Cursor'(Position.Container, Result); end Find_In_Subtree; function Find_In_Subtree Index: a-comutr.ads =================================================================== --- a-comutr.ads (revision 178155) +++ a-comutr.ads (working copy) @@ -113,15 +113,37 @@ (Container : Tree; Item : Element_Type) return Cursor; + -- This version of the AI: + -- 10-06-02 AI05-0136-1/07 + -- declares Find_In_Subtree this way: + -- + -- function Find_In_Subtree + -- (Container : Tree; + -- Item : Element_Type; + -- Position : Cursor) return Cursor; + -- + -- It seems that the Container parameter is there by mistake, but we need + -- an official ruling from the ARG. ??? + function Find_In_Subtree - (Container : Tree; - Item : Element_Type; - Position : Cursor) return Cursor; + (Position : Cursor; + Item : Element_Type) return Cursor; + -- This version of the AI: + -- 10-06-02 AI05-0136-1/07 + -- declares Ancestor_Find this way: + -- + -- function Ancestor_Find + -- (Container : Tree; + -- Item : Element_Type; + -- Position : Cursor) return Cursor; + -- + -- It seems that the Container parameter is there by mistake, but we need + -- an official ruling from the ARG. ??? + function Ancestor_Find - (Container : Tree; - Item : Element_Type; - Position : Cursor) return Cursor; + (Position : Cursor; + Item : Element_Type) return Cursor; function Contains (Container : Tree; Index: a-cbmutr.adb =================================================================== --- a-cbmutr.adb (revision 178184) +++ a-cbmutr.adb (working copy) @@ -286,22 +286,22 @@ ------------------- function Ancestor_Find - (Container : Tree; - Item : Element_Type; - Position : Cursor) return Cursor + (Position : Cursor; + Item : Element_Type) return Cursor is - R : constant Count_Type := Root_Node (Container); - N : Count_Type; + R, N : Count_Type; begin if Position = No_Element then raise Constraint_Error with "Position cursor has no element"; end if; - if Position.Container /= Container'Unrestricted_Access then - raise Program_Error with "Position cursor not in container"; - end if; + -- Commented-out pending ruling by ARG. ??? + -- if Position.Container /= Container'Unrestricted_Access then + -- raise Program_Error with "Position cursor not in container"; + -- end if; + -- AI-0136 says to raise PE if Position equals the root node. This does -- not seem correct, as this value is just the limiting condition of the -- search. For now we omit this check, pending a ruling from the ARG. @@ -311,13 +311,14 @@ -- raise Program_Error with "Position cursor designates root"; -- end if; + R := Root_Node (Position.Container.all); N := Position.Node; while N /= R loop - if Container.Elements (N) = Item then - return Cursor'(Container'Unrestricted_Access, N); + if Position.Container.Elements (N) = Item then + return Cursor'(Position.Container, N); end if; - N := Container.Nodes (N).Parent; + N := Position.Container.Nodes (N).Parent; end loop; return No_Element; @@ -1289,9 +1290,8 @@ --------------------- function Find_In_Subtree - (Container : Tree; - Item : Element_Type; - Position : Cursor) return Cursor + (Position : Cursor; + Item : Element_Type) return Cursor is Result : Count_Type; @@ -1300,27 +1300,35 @@ raise Constraint_Error with "Position cursor has no element"; end if; - if Position.Container /= Container'Unrestricted_Access then - raise Program_Error with "Position cursor not in container"; - end if; + -- Commented-out pending ruling by ARG. ??? - if Container.Count = 0 then + -- if Position.Container /= Container'Unrestricted_Access then + -- raise Program_Error with "Position cursor not in container"; + -- end if; + + if Position.Container.Count = 0 then pragma Assert (Is_Root (Position)); return No_Element; end if; if Is_Root (Position) then - Result := Find_In_Children (Container, Position.Node, Item); + Result := Find_In_Children + (Container => Position.Container.all, + Subtree => Position.Node, + Item => Item); else - Result := Find_In_Subtree (Container, Position.Node, Item); + Result := Find_In_Subtree + (Container => Position.Container.all, + Subtree => Position.Node, + Item => Item); end if; if Result = 0 then return No_Element; end if; - return Cursor'(Container'Unrestricted_Access, Result); + return Cursor'(Position.Container, Result); end Find_In_Subtree; function Find_In_Subtree Index: a-cbmutr.ads =================================================================== --- a-cbmutr.ads (revision 178155) +++ a-cbmutr.ads (working copy) @@ -113,22 +113,36 @@ Item : Element_Type) return Cursor; -- This version of the AI: + -- 10-06-02 AI05-0136-1/07 + -- declares Find_In_Subtree this way: + -- + -- function Find_In_Subtree + -- (Container : Tree; + -- Item : Element_Type; + -- Position : Cursor) return Cursor; + -- + -- It seems that the Container parameter is there by mistake, but we need + -- an official ruling from the ARG. ??? - -- 10-06-02 AI05-0136-1/07 + function Find_In_Subtree + (Position : Cursor; + Item : Element_Type) return Cursor; - -- declares Find_In_Subtree with a Container parameter, but this seems - -- incorrect. We need a ruling from the ARG about whether this really was - -- intended. ??? + -- This version of the AI: + -- 10-06-02 AI05-0136-1/07 + -- declares Ancestor_Find this way: + -- + -- function Ancestor_Find + -- (Container : Tree; + -- Item : Element_Type; + -- Position : Cursor) return Cursor; + -- + -- It seems that the Container parameter is there by mistake, but we need + -- an official ruling from the ARG. ??? - function Find_In_Subtree - (Container : Tree; - Item : Element_Type; - Position : Cursor) return Cursor; - function Ancestor_Find - (Container : Tree; - Item : Element_Type; - Position : Cursor) return Cursor; + (Position : Cursor; + Item : Element_Type) return Cursor; function Contains (Container : Tree;