OSDN Git Service

2009-08-28 Sebastian Pop <sebastian.pop@amd.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / checks.ads
index c92e9cb..1acdab1 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2007, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2008, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -32,7 +32,7 @@
 --  checks, is to attempt to detect at compilation time that a constraint
 --  error will occur. If this is detected a warning or error is issued and the
 --  offending expression or statement replaced with a constraint error node.
---  This always occurs whether checks are suppressed or not.  Dynamic range
+--  This always occurs whether checks are suppressed or not. Dynamic range
 --  checks are, of course, not inserted if checks are suppressed.
 
 with Namet;  use Namet;
@@ -102,11 +102,15 @@ package Checks is
    --  Determines whether an expression node requires a runtime access
    --  check and if so inserts the appropriate run-time check.
 
-   procedure Apply_Accessibility_Check (N : Node_Id; Typ : Entity_Id);
+   procedure Apply_Accessibility_Check
+     (N           : Node_Id;
+      Typ         : Entity_Id;
+      Insert_Node : Node_Id);
    --  Given a name N denoting an access parameter, emits a run-time
    --  accessibility check (if necessary), checking that the level of
    --  the object denoted by the access parameter is not deeper than the
    --  level of the type Typ. Program_Error is raised if the check fails.
+   --  Insert_Node indicates the node where the check should be inserted.
 
    procedure Apply_Address_Clause_Check (E : Entity_Id; N : Node_Id);
    --  E is the entity for an object which has an address clause. If checks
@@ -131,9 +135,9 @@ package Checks is
       Typ        : Entity_Id;
       No_Sliding : Boolean := False);
    --  Top-level procedure, calls all the others depending on the class of Typ.
-   --  Checks that expression N verifies the constraint of type Typ. No_Sliding
-   --  is only relevant for constrained array types, id set to true, it
-   --  checks that indexes are in range.
+   --  Checks that expression N satisfies the constraint of type Typ.
+   --  No_Sliding is only relevant for constrained array types, if set to True,
+   --  it checks that indexes are in range.
 
    procedure Apply_Discriminant_Check
      (N   : Node_Id;
@@ -180,10 +184,11 @@ package Checks is
    --  to make sure that the universal result is in range.
 
    procedure Determine_Range
-     (N  : Node_Id;
-      OK : out Boolean;
-      Lo : out Uint;
-      Hi : out Uint);
+     (N            : Node_Id;
+      OK           : out Boolean;
+      Lo           : out Uint;
+      Hi           : out Uint;
+      Assume_Valid : Boolean := False);
    --  N is a node for a subexpression. If N is of a discrete type with no
    --  error indications, and no other peculiarities (e.g. missing type
    --  fields), then OK is True on return, and Lo and Hi are set to a
@@ -193,7 +198,10 @@ package Checks is
    --  type, or some kind of error condition is detected, then OK is False on
    --  exit, and Lo/Hi are set to No_Uint. Thus the significance of OK being
    --  False on return is that no useful information is available on the range
-   --  of the expression.
+   --  of the expression. Assume_Valid determines whether the processing is
+   --  allowed to assume that values are in range of their subtypes. If it is
+   --  set to True, then this assumption is valid, if False, then processing
+   --  is done using base types to allow invalid values.
 
    procedure Install_Null_Excluding_Check (N : Node_Id);
    --  Determines whether an access node requires a runtime access check and
@@ -206,12 +214,14 @@ package Checks is
    --  Range checks are controlled by the Do_Range_Check flag. The front end
    --  is responsible for setting this flag in relevant nodes. Originally
    --  the back end generated all corresponding range checks. But later on
-   --  we decided to generate all range checks in the front end. We are now
+   --  we decided to generate many range checks in the front end. We are now
    --  in the transitional phase where some of these checks are still done
-   --  by the back end, but many are done by the front end.
+   --  by the back end, but many are done by the front end. It is possible
+   --  that in the future we might move all the checks to the front end. The
+   --  main remaining back end checks are for subscript checking.
 
    --  Overflow checks are similarly controlled by the Do_Overflow_Check flag.
-   --  The difference here is that if Backend_Overflow_Checks is is
+   --  The difference here is that if back end overflow checks are inactive
    --  (Backend_Overflow_Checks_On_Target set False), then the actual overflow
    --  checks are generated by the front end, but if back end overflow checks
    --  are active (Backend_Overflow_Checks_On_Target set True), then the back
@@ -225,9 +235,9 @@ package Checks is
    --  First this routine determines if an overflow check is needed by doing
    --  an appropriate range check. If a check is not needed, then the call
    --  has no effect. If a check is needed then this routine sets the flag
-   --  Set 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.
+   --  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.
 
    procedure Enable_Range_Check (N : Node_Id);
    --  Set Do_Range_Check flag in node N True, unless it can be determined
@@ -437,7 +447,7 @@ package Checks is
    --  Some of the earlier processing for checks results in temporarily setting
    --  the Do_Range_Check flag rather than actually generating checks. Now we
    --  are moving the generation of such checks into the front end for reasons
-   --  of efficiency and simplicity (there were difficutlies in handling this
+   --  of efficiency and simplicity (there were difficulties in handling this
    --  in the back end when side effects were present in the expressions being
    --  checked).