From 4dd80bb73b99a1b1b01ffca9871a63b31b6f03d1 Mon Sep 17 00:00:00 2001 From: Quentin Ochem Date: Wed, 6 Aug 2008 10:32:09 +0200 Subject: [PATCH] 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 * 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 --- gcc/ada/s-stausa.adb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/gcc/ada/s-stausa.adb b/gcc/ada/s-stausa.adb index d9b972d8b289..ff5f86e1668c 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 -- 2.47.2