From patchwork Fri Nov 4 14:02:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 123643 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 16F13B6F90 for ; Sat, 5 Nov 2011 01:02:48 +1100 (EST) Received: (qmail 26278 invoked by alias); 4 Nov 2011 14:02:38 -0000 Received: (qmail 26249 invoked by uid 22791); 4 Nov 2011 14:02:33 -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; Fri, 04 Nov 2011 14:02:17 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 1ACCC2BB090; Fri, 4 Nov 2011 10:02:16 -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 3jlZKb+hCO8X; Fri, 4 Nov 2011 10:02:16 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id ECF142BAFD9; Fri, 4 Nov 2011 10:02:15 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id EBA623FEE8; Fri, 4 Nov 2011 10:02:15 -0400 (EDT) Date: Fri, 4 Nov 2011 10:02:15 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Matthew Heaney Subject: [Ada] Change semantics of Merge Message-ID: <20111104140215.GA20911@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 semantics of Merge changed slightly per AI05-0021. It was originally the case that if Target and Source denoted the same container object, then the GNAT implementation of Merge did nothing. However, it was argued that RM05 did not precisely specify the semantics for this corner case. The decision of the ARG was that if Target and Source denote the same non-empty container object, then Program_Error is raised. The text of AI05-0021 can be found here: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai05s/ai05-0021-1.txt Tested on x86_64-pc-linux-gnu, committed on trunk 2011-11-04 Matthew Heaney * a-convec.adb, a-coinve.adb, a-cobove.adb (Merge): Raise PE when Target and Source denote same non-empty object * a-cdlili.adb, a-cidlli.adb, a-cbdlli.adb (Merge): Ditto Index: a-cdlili.adb =================================================================== --- a-cdlili.adb (revision 180934) +++ a-cdlili.adb (working copy) @@ -515,10 +515,24 @@ LI, RI : Cursor; begin - if Target'Address = Source'Address then + + -- The semantics of Merge changed slightly per AI05-0021. It was + -- originally the case that if Target and Source denoted the same + -- container object, then the GNAT implementation of Merge did + -- nothing. However, it was argued that RM05 did not precisely + -- specify the semantics for this corner case. The decision of the + -- ARG was that if Target and Source denote the same non-empty + -- container object, then Program_Error is raised. + + if Source.Is_Empty then return; end if; + if Target'Address = Source'Address then + raise Program_Error with + "Target and Source denote same non-empty container"; + end if; + if Target.Busy > 0 then raise Program_Error with "attempt to tamper with cursors of Target (list is busy)"; Index: a-coinve.adb =================================================================== --- a-coinve.adb (revision 180934) +++ a-coinve.adb (working copy) @@ -1268,16 +1268,26 @@ I, J : Index_Type'Base; begin - if Target.Last < Index_Type'First then - Move (Target => Target, Source => Source); + + -- The semantics of Merge changed slightly per AI05-0021. It was + -- originally the case that if Target and Source denoted the same + -- container object, then the GNAT implementation of Merge did + -- nothing. However, it was argued that RM05 did not precisely + -- specify the semantics for this corner case. The decision of the + -- ARG was that if Target and Source denote the same non-empty + -- container object, then Program_Error is raised. + + if Source.Last < Index_Type'First then -- Source is empty return; end if; if Target'Address = Source'Address then - return; + raise Program_Error with + "Target and Source denote same non-empty container"; end if; - if Source.Last < Index_Type'First then + if Target.Last < Index_Type'First then -- Target is empty + Move (Target => Target, Source => Source); return; end if; Index: a-cidlli.adb =================================================================== --- a-cidlli.adb (revision 180934) +++ a-cidlli.adb (working copy) @@ -563,10 +563,24 @@ LI, RI : Cursor; begin - if Target'Address = Source'Address then + + -- The semantics of Merge changed slightly per AI05-0021. It was + -- originally the case that if Target and Source denoted the same + -- container object, then the GNAT implementation of Merge did + -- nothing. However, it was argued that RM05 did not precisely + -- specify the semantics for this corner case. The decision of the + -- ARG was that if Target and Source denote the same non-empty + -- container object, then Program_Error is raised. + + if Source.Is_Empty then return; end if; + if Target'Address = Source'Address then + raise Program_Error with + "Target and Source denote same non-empty container"; + end if; + if Target.Busy > 0 then raise Program_Error with "attempt to tamper with cursors of Target (list is busy)"; Index: a-cobove.adb =================================================================== --- a-cobove.adb (revision 180934) +++ a-cobove.adb (working copy) @@ -788,16 +788,26 @@ I, J : Count_Type; begin - if Target.Is_Empty then - Move (Target => Target, Source => Source); + + -- The semantics of Merge changed slightly per AI05-0021. It was + -- originally the case that if Target and Source denoted the same + -- container object, then the GNAT implementation of Merge did + -- nothing. However, it was argued that RM05 did not precisely + -- specify the semantics for this corner case. The decision of the + -- ARG was that if Target and Source denote the same non-empty + -- container object, then Program_Error is raised. + + if Source.Is_Empty then return; end if; if Target'Address = Source'Address then - return; + raise Program_Error with + "Target and Source denote same non-empty container"; end if; - if Source.Is_Empty then + if Target.Is_Empty then + Move (Target => Target, Source => Source); return; end if; Index: a-convec.adb =================================================================== --- a-convec.adb (revision 180934) +++ a-convec.adb (working copy) @@ -909,16 +909,26 @@ J : Index_Type'Base; begin - if Target.Last < Index_Type'First then - Move (Target => Target, Source => Source); + + -- The semantics of Merge changed slightly per AI05-0021. It was + -- originally the case that if Target and Source denoted the same + -- container object, then the GNAT implementation of Merge did + -- nothing. However, it was argued that RM05 did not precisely + -- specify the semantics for this corner case. The decision of the + -- ARG was that if Target and Source denote the same non-empty + -- container object, then Program_Error is raised. + + if Source.Last < Index_Type'First then -- Source is empty return; end if; if Target'Address = Source'Address then - return; + raise Program_Error with + "Target and Source denote same non-empty container"; end if; - if Source.Last < Index_Type'First then + if Target.Last < Index_Type'First then -- Target is empty + Move (Target => Target, Source => Source); return; end if; Index: a-cbdlli.adb =================================================================== --- a-cbdlli.adb (revision 180934) +++ a-cbdlli.adb (working copy) @@ -713,10 +713,24 @@ LI, RI : Cursor; begin - if Target'Address = Source'Address then + + -- The semantics of Merge changed slightly per AI05-0021. It was + -- originally the case that if Target and Source denoted the same + -- container object, then the GNAT implementation of Merge did + -- nothing. However, it was argued that RM05 did not precisely + -- specify the semantics for this corner case. The decision of the + -- ARG was that if Target and Source denote the same non-empty + -- container object, then Program_Error is raised. + + if Source.Is_Empty then return; end if; + if Target'Address = Source'Address then + raise Program_Error with + "Target and Source denote same non-empty container"; + end if; + if Target.Busy > 0 then raise Program_Error with "attempt to tamper with cursors of Target (list is busy)";