diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-11-30 16:08:37 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-11-30 16:08:37 +0000 |
commit | d36a3269d0e6c5b34a0cf85c75e416186176b01d (patch) | |
tree | 9fe7bb7e1792a568a310d0ca746ddff32e9cb8b8 /gcc/ada/a-coinve.adb | |
parent | f648ee3f0265eb917e18fca4383aff5c08207c72 (diff) | |
download | gcc-d36a3269d0e6c5b34a0cf85c75e416186176b01d.tar.gz |
2009-11-30 Matthew Heaney <heaney@adacore.com>
* a-coinve.adb (Insert): Move exception handler closer to point where
exception can occur.
Minor reformatting & comment additions.
2009-11-30 Arnaud Charlet <charlet@adacore.com>
* freeze.adb (Freeze_Entity): Disable warning on 'Foreign caller must
pass bounds' for VM targets, not relevant.
2009-11-30 Robert Dewar <dewar@adacore.com>
* sem_util.adb (Wrong_Type): Diagnose additional case of modular
missing parens.
* a-tiinio.adb, a-wtinio.adb, a-ztinio.adb: Minor reformatting
* exp_util.adb (Kill_Dead_Code): Suppress warning for some additional
cases.
* sem_warn.adb (Set_Warning_Flag): Clean up gnatwA list and ensure
completeness.
(Set_Dot_Warning_Flag): Ditto for -gnatw.e
(Set_Dot_Warning_Flag): Implement -gnbatw.v/w.V
* usage.adb: Add lines for -gnatw.v/w.V
2009-11-30 Emmanuel Briot <briot@adacore.com>
* make.adb (Check_Standard_Library): use Full_Source_Name instead of
direct call to Find_File. The former provides caching of the results, so
might be more efficient
(Start_Compile_If_Necessary): Add comment on possible optimization,
not done for now.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154825 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-coinve.adb')
-rw-r--r-- | gcc/ada/a-coinve.adb | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/gcc/ada/a-coinve.adb b/gcc/ada/a-coinve.adb index 9169e086ebd..84ad22ec1f9 100644 --- a/gcc/ada/a-coinve.adb +++ b/gcc/ada/a-coinve.adb @@ -1121,21 +1121,45 @@ package body Ada.Containers.Indefinite_Vectors is Index : constant Index_Type := Index_Type (Index_As_Int); - J : Index_Type'Base := Before; + J : Index_Type'Base; begin + -- The new items are being inserted in the middle of the + -- array, in the range [Before, Index). Copy the existing + -- elements to the end of the array, to make room for the + -- new items. + E (Index .. New_Last) := E (Before .. Container.Last); Container.Last := New_Last; - while J < Index loop - E (J) := new Element_Type'(New_Item); - J := J + 1; - end loop; + -- We have copied the existing items up to the end of the + -- array, to make room for the new items in the middle of + -- the array. Now we actually allocate the new items. - exception - when others => - E (J .. Index - 1) := (others => null); - raise; + -- Note: initialize J outside loop to make it clear that + -- J always has a value if the exception handler triggers. + + J := Before; + begin + while J < Index loop + E (J) := new Element_Type'(New_Item); + J := J + 1; + end loop; + + exception + when others => + + -- Values in the range [Before, J) were successfully + -- allocated, but values in the range [J, Index) are + -- stale (these array positions contain copies of the + -- old items, that did not get assigned a new item, + -- because the allocation failed). We must finish what + -- we started by clearing out all of the stale values, + -- leaving a "hole" in the middle of the array. + + E (J .. Index - 1) := (others => null); + raise; + end; end; else @@ -1149,6 +1173,9 @@ package body Ada.Containers.Indefinite_Vectors is return; end if; + -- There follows LOTS of code completely devoid of comments ??? + -- This is not our general style ??? + declare C, CC : UInt; |