diff options
author | Quentin Ochem <ochem@adacore.com> | 2008-08-06 10:32:09 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2008-08-06 10:32:09 +0200 |
commit | 4dd80bb73b99a1b1b01ffca9871a63b31b6f03d1 (patch) | |
tree | 5d77f0d536f21c798468ed4742933e683b4ac775 | |
parent | 1a9a686e312f60716594fd45466b1adb827371ef (diff) | |
download | gcc-4dd80bb73b99a1b1b01ffca9871a63b31b6f03d1.zip gcc-4dd80bb73b99a1b1b01ffca9871a63b31b6f03d1.tar.gz gcc-4dd80bb73b99a1b1b01ffca9871a63b31b6f03d1.tar.bz2 |
s-stausa.adb (Fill_Stack): Fixed pragma assert and top pattern mark in the case of an empty pattern size.
2008-08-06 Quentin Ochem <ochem@adacore.com>
* s-stausa.adb (Fill_Stack): Fixed pragma assert and top pattern mark
in the case of an empty pattern size.
(Compute_Result): Do not do any computation in the case of an empty
pattern size.
(Report_Result): Fixed computation of the overflow guard.
From-SVN: r138771
-rw-r--r-- | gcc/ada/s-stausa.adb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/gcc/ada/s-stausa.adb b/gcc/ada/s-stausa.adb index d9b972d..ff5f86e 100644 --- a/gcc/ada/s-stausa.adb +++ b/gcc/ada/s-stausa.adb @@ -298,7 +298,7 @@ package body System.Stack_Usage is To_Stack_Address (Stack (Top_Slot_Index_In (Stack))'Address); else Analyzer.Bottom_Pattern_Mark := To_Stack_Address (Stack'Address); - Analyzer.Bottom_Pattern_Mark := To_Stack_Address (Stack'Address); + Analyzer.Top_Pattern_Mark := To_Stack_Address (Stack'Address); end if; -- If Arr has been packed, the following assertion must be true (we @@ -306,7 +306,8 @@ package body System.Stack_Usage is -- Min (Analyzer.Inner_Pattern_Mark, Analyzer.Outer_Pattern_Mark)): pragma Assert - (Analyzer.Pattern_Size = + (Analyzer.Pattern_Size = 0 or else + Analyzer.Pattern_Size = Stack_Size (Analyzer.Top_Pattern_Mark, Analyzer.Bottom_Pattern_Mark)); end; @@ -381,6 +382,10 @@ package body System.Stack_Usage is begin Analyzer.Topmost_Touched_Mark := Analyzer.Bottom_Pattern_Mark; + if Analyzer.Pattern_Size = 0 then + return; + end if; + -- Look backward from the topmost possible end of the marked stack to -- the bottom of it. The first index not equals to the patterns marks -- the beginning of the used stack. @@ -559,20 +564,23 @@ package body System.Stack_Usage is Min_Measure => 0, Max_Measure => 0); + Overflow_Guard : constant Integer := + Analyzer.Stack_Size + - Stack_Size (Analyzer.Top_Pattern_Mark, Analyzer.Bottom_Of_Stack); + begin if Analyzer.Pattern_Size = 0 then -- If we have that result, it means that we didn't do any computation -- at all. In other words, we used at least everything (and possibly -- more). - Result.Min_Measure := Analyzer.Stack_Size; + Result.Min_Measure := Analyzer.Stack_Size - Overflow_Guard; Result.Max_Measure := Analyzer.Stack_Size; else Result.Min_Measure := Stack_Size (Analyzer.Topmost_Touched_Mark, Analyzer.Bottom_Of_Stack); - Result.Max_Measure := Result.Min_Measure + - (Analyzer.Stack_Size - Analyzer.Pattern_Size); + Result.Max_Measure := Result.Min_Measure + Overflow_Guard; end if; if Analyzer.Result_Id in Result_Array'Range then |