summaryrefslogtreecommitdiff
path: root/gcc/ada/checks.ads
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-06 11:11:15 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-06 11:11:15 +0000
commit0df9d43fd26ed0f083bd65e59a097d75dd067a44 (patch)
treebf5fc789888a9885070c8aefd76af66e8c2fcc68 /gcc/ada/checks.ads
parent104ebae15f1b1c9fa250763c65413edde6e5f15a (diff)
downloadgcc-0df9d43fd26ed0f083bd65e59a097d75dd067a44.tar.gz
2012-11-06 Robert Dewar <dewar@adacore.com>
* checks.ads, checks.adb, exp_ch4.adb: Minor changes throughout for new overflow checking. * exp_util.adb (Insert_Actions): Remove special casing of Overflow_Check. * gnat1drv.adb (Adjust_Global_Switches): Fixes for new handling of overflow checks. * sem.adb (Analyze): Remove special casing of Overflow_Check (Analyze_List): ditto. * sem_prag.adb (Analyze_Pragma, case Overflow_Checks): Remove SUPPRESSED and change CHECKED to STRICT. * sem_res.adb (Analyze_And_Resolve): No longer treat Overflow_Check specially. (Preanalyze_And_Resolve): ditto. (Resolve): ditto. * snames.ads-tmpl: Replace Name_Checked by Name_Strict. * switch-c.adb (Get_Overflow_Mode): Eliminate 0 setting, CHECKED => STRICT. * types.ads (Overflow_Check_Type): Remove Suppressed, change Checked to Strict (Suppress_Record): Overflow check controlled by Suppress array. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193233 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/checks.ads')
-rw-r--r--gcc/ada/checks.ads45
1 files changed, 23 insertions, 22 deletions
diff --git a/gcc/ada/checks.ads b/gcc/ada/checks.ads
index f7a4399386d..f2919e2ad60 100644
--- a/gcc/ada/checks.ads
+++ b/gcc/ada/checks.ads
@@ -72,12 +72,11 @@ package Checks is
-- determine whether check C is suppressed either on the entity E or
-- as the result of a scope suppress pragma. If Checks_May_Be_Suppressed
-- is False, then the status of the check can be determined simply by
- -- examining Scope_Checks (C), so this routine is not called in that case.
+ -- examining Scope_Suppress, so this routine is not called in that case.
- function Overflow_Check_Mode (E : Entity_Id) return Overflow_Check_Type;
+ function Overflow_Check_Mode return Overflow_Check_Type;
-- Returns current overflow checking mode, taking into account whether
- -- we are inside an assertion expression. Always returns Suppressed if
- -- overflow checks are suppressed for entity E.
+ -- we are inside an assertion expression.
-------------------------------------------
-- Procedures to Activate Checking Flags --
@@ -142,7 +141,10 @@ package Checks is
-- overflow checking for dependent expressions. This routine handles
-- front end vs back end overflow checks (in the front end case it expands
-- the necessary check). Note that divide is handled separately using
- -- Apply_Divide_Checks.
+ -- Apply_Divide_Checks. Node N may or may not have Do_Overflow_Check.
+ -- In STRICT mode, there is nothing to do if this flag is off, but in
+ -- MINIMIZED/ELIMINATED mode we still have to deal with possible use
+ -- of doing operations in Long_Long_Integer or Bignum mode.
procedure Apply_Constraint_Check
(N : Node_Id;
@@ -266,15 +268,16 @@ package Checks is
-- Insert_Action of the whole block (it is returned unanalyzed). The Loc
-- parameter is used to supply Sloc values for the constructed tree.
- procedure Minimize_Eliminate_Overflow_Checks
+ procedure Minimize_Eliminate_Overflows
(N : Node_Id;
Lo : out Uint;
Hi : out Uint;
Top_Level : Boolean);
-- This is the main routine for handling MINIMIZED and ELIMINATED overflow
- -- checks. On entry N is a node whose result is a signed integer subtype.
- -- If the node is an arithmetic operation, then a range analysis is carried
- -- out, and there are three possibilities:
+ -- processing. On entry N is a node whose result is a signed integer
+ -- subtype. The Do_Overflow_Check flag may or may not be set on N. If the
+ -- node is an arithmetic operation, then a range analysis is carried out,
+ -- and there are three possibilities:
--
-- The node is left unchanged (apart from expansion of an exponentiation
-- operation). This happens if the routine can determine that the result
@@ -313,16 +316,16 @@ package Checks is
-- The routine is called in three situations if we are operating in either
-- MINIMIZED or ELIMINATED modes.
--
- -- Overflow checks applied to the top node of an expression tree when
+ -- Overflow processing applied to the top node of an expression tree when
-- that node is an arithmetic operator. In this case the result is
-- converted to the appropriate result type (there is special processing
-- when the parent is a conversion, see body for details).
--
- -- Overflow checks are applied to the operands of a comparison operation.
+ -- Overflow processing applied to the operands of a comparison operation.
-- In this case, the comparison is done on the result Long_Long_Integer
-- or Bignum values, without raising any exceptions.
--
- -- Overflow checks are applied to the left operand of a membership test.
+ -- Overflow processing applied to the left operand of a membership test.
-- In this case no exception is raised if a Long_Long_Integer or Bignum
-- result is outside the range of the type of that left operand (it is
-- just that the result of IN is false in that case).
@@ -332,13 +335,13 @@ package Checks is
--
-- Top_Level is used to avoid inefficient unnecessary transitions into the
-- Bignum domain. If Top_Level is True, it means that the caller will have
- -- to convert any Bignum value back to Long_Long_Integer, checking that the
- -- value is in range. This is the normal case for a top level operator in
- -- a subexpression. There is no point in going into Bignum mode to avoid an
- -- overflow just so we can check for overflow the next moment. For calls
- -- from comparisons and membership tests, and for all recursive calls, we
- -- do want to transition into the Bignum domain if necessary. Note that
- -- this setting is only relevant in ELIMINATED mode.
+ -- to convert any Bignum value back to Long_Long_Integer, possibly checking
+ -- that the value is in range. This is the normal case for a top level
+ -- operator in a subexpression. There is no point in going into Bignum mode
+ -- to avoid an overflow just so we can check for overflow the next moment.
+ -- For calls from comparisons and membership tests, and for all recursive
+ -- calls, we do want to transition into the Bignum domain if necessary.
+ -- Note that this setting is only relevant in ELIMINATED mode.
-------------------------------------------------------
-- Control and Optimization of Range/Overflow Checks --
@@ -370,9 +373,7 @@ package Checks is
-- has no effect. If a check is needed then this routine sets the flag
-- Do_Overflow_Check in node N to True, unless it can be determined that
-- the check is not needed. The only condition under which this is the
- -- case is if there was an identical check earlier on. These optimziations
- -- apply to CHECKED mode, but not to MINIMIZED/ELIMINATED modes. See the
- -- body for a full explanation.
+ -- case is if there was an identical check earlier on.
procedure Enable_Range_Check (N : Node_Id);
-- Set Do_Range_Check flag in node N True, unless it can be determined