]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Present and No functions for type Uint
authorBob Duff <duff@adacore.com>
Tue, 29 Jun 2021 00:02:20 +0000 (20:02 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 20 Sep 2021 12:31:37 +0000 (12:31 +0000)
gcc/ada/

* uintp.ads, uintp.adb (Present, No): New functions for
comparing with No_Uint.
* checks.adb, einfo-utils.adb, exp_aggr.adb, exp_attr.adb,
exp_ch3.adb, exp_ch4.adb, exp_dbug.adb, exp_disp.adb,
exp_util.adb, repinfo.adb, repinfo-input.adb, scn.adb,
sem_attr.adb, sem_ch13.adb, sem_eval.adb, sem_util.adb,
sinfo-utils.adb, treepr.adb: Use Present (...) instead of "...
/= No_Uint", and No (...) instead of "... = No_Uint".

20 files changed:
gcc/ada/checks.adb
gcc/ada/einfo-utils.adb
gcc/ada/exp_aggr.adb
gcc/ada/exp_attr.adb
gcc/ada/exp_ch3.adb
gcc/ada/exp_ch4.adb
gcc/ada/exp_dbug.adb
gcc/ada/exp_disp.adb
gcc/ada/exp_util.adb
gcc/ada/repinfo-input.adb
gcc/ada/repinfo.adb
gcc/ada/scn.adb
gcc/ada/sem_attr.adb
gcc/ada/sem_ch13.adb
gcc/ada/sem_eval.adb
gcc/ada/sem_util.adb
gcc/ada/sinfo-utils.adb
gcc/ada/treepr.adb
gcc/ada/uintp.adb
gcc/ada/uintp.ads

index cebeac5ab0c7ddaa5c97c1eed67b249a3ebecffd..292a620a1ddce2390a0f770c8bae79e294d5fecd 100644 (file)
@@ -9059,7 +9059,7 @@ package body Checks is
 
       function In_Result_Range return Boolean is
       begin
-         if Lo = No_Uint or else Hi = No_Uint then
+         if No (Lo) or else No (Hi) then
             return False;
 
          elsif Is_OK_Static_Subtype (Etype (N)) then
@@ -9080,7 +9080,7 @@ package body Checks is
 
       procedure Max (A : in out Uint; B : Uint) is
       begin
-         if A = No_Uint or else B > A then
+         if No (A) or else B > A then
             A := B;
          end if;
       end Max;
@@ -9091,7 +9091,7 @@ package body Checks is
 
       procedure Min (A : in out Uint; B : Uint) is
       begin
-         if A = No_Uint or else B < A then
+         if No (A) or else B < A then
             A := B;
          end if;
       end Min;
@@ -9197,14 +9197,14 @@ package body Checks is
             Minimize_Eliminate_Overflows
               (Then_DE, Lo, Hi, Top_Level => False);
 
-            if Lo = No_Uint then
+            if No (Lo) then
                Bignum_Operands := True;
             end if;
 
             Minimize_Eliminate_Overflows
               (Else_DE, Rlo, Rhi, Top_Level => False);
 
-            if Rlo = No_Uint then
+            if No (Rlo) then
                Bignum_Operands := True;
             else
                Long_Long_Integer_Operands :=
@@ -9279,7 +9279,7 @@ package body Checks is
                   Minimize_Eliminate_Overflows
                     (Aexp, Lo, Hi, Top_Level => False);
 
-                  if Lo = No_Uint then
+                  if No (Lo) then
                      Bignum_Operands := True;
                   elsif Etype (Aexp) = LLIB then
                      Long_Long_Integer_Operands := True;
@@ -9368,7 +9368,7 @@ package body Checks is
       --  numbers at compile time for very little gain (the number of cases
       --  in which we could slip back from bignum mode is small).
 
-      if Rlo = No_Uint or else (Binary and then Llo = No_Uint) then
+      if No (Rlo) or else (Binary and then No (Llo)) then
          Lo := No_Uint;
          Hi := No_Uint;
          Bignum_Operands := True;
@@ -9441,7 +9441,7 @@ package body Checks is
       --  0 .. 1, but the cases are rare and it is not worth the effort.
       --  Failing to do this switching back is only an efficiency issue.
 
-      elsif Lo = No_Uint or else Lo < LLLo or else Hi > LLHi then
+      elsif No (Lo) or else Lo < LLLo or else Hi > LLHi then
 
          --  OK, we are definitely outside the range of Long_Long_Integer. The
          --  question is whether to move to Bignum mode, or stay in the domain
@@ -11306,7 +11306,7 @@ package body Checks is
                     renames Alignment_Warnings.Table (J);
          begin
             if Known_Alignment (AWR.E)
-              and then ((AWR.A /= No_Uint
+              and then ((Present (AWR.A)
                           and then AWR.A mod Alignment (AWR.E) = 0)
                         or else (Present (AWR.P)
                                   and then Has_Compatible_Alignment
index 5782bd602c9da11a46e8f6d9d68e31b62b99fc53..d805889dd872ae7b6690357832e0cf9c3084b532 100644 (file)
@@ -384,19 +384,19 @@ package body Einfo.Utils is
 
    function Known_Component_Bit_Offset            (E : Entity_Id) return B is
    begin
-      return Component_Bit_Offset (E) /= No_Uint;
+      return Present (Component_Bit_Offset (E));
    end Known_Component_Bit_Offset;
 
    function Known_Static_Component_Bit_Offset     (E : Entity_Id) return B is
    begin
-      return Component_Bit_Offset (E) /= No_Uint
+      return Present (Component_Bit_Offset (E))
         and then Component_Bit_Offset (E) >= Uint_0;
    end Known_Static_Component_Bit_Offset;
 
    function Known_Component_Size                  (E : Entity_Id) return B is
    begin
       return Component_Size (E) /= Uint_0
-        and then Component_Size (E) /= No_Uint;
+        and then Present (Component_Size (E));
    end Known_Component_Size;
 
    function Known_Static_Component_Size           (E : Entity_Id) return B is
@@ -407,7 +407,7 @@ package body Einfo.Utils is
    function Known_Esize                           (E : Entity_Id) return B is
    begin
       return Esize (E) /= Uint_0
-        and then Esize (E) /= No_Uint;
+        and then Present (Esize (E));
    end Known_Esize;
 
    function Known_Static_Esize                    (E : Entity_Id) return B is
@@ -428,29 +428,29 @@ package body Einfo.Utils is
 
    function Known_Normalized_First_Bit            (E : Entity_Id) return B is
    begin
-      return Normalized_First_Bit (E) /= No_Uint;
+      return Present (Normalized_First_Bit (E));
    end Known_Normalized_First_Bit;
 
    function Known_Static_Normalized_First_Bit     (E : Entity_Id) return B is
    begin
-      return Normalized_First_Bit (E) /= No_Uint
+      return Present (Normalized_First_Bit (E))
         and then Normalized_First_Bit (E) >= Uint_0;
    end Known_Static_Normalized_First_Bit;
 
    function Known_Normalized_Position             (E : Entity_Id) return B is
    begin
-      return Normalized_Position (E) /= No_Uint;
+      return Present (Normalized_Position (E));
    end Known_Normalized_Position;
 
    function Known_Static_Normalized_Position      (E : Entity_Id) return B is
    begin
-      return Normalized_Position (E) /= No_Uint
+      return Present (Normalized_Position (E))
         and then Normalized_Position (E) >= Uint_0;
    end Known_Static_Normalized_Position;
 
    function Known_RM_Size                         (E : Entity_Id) return B is
    begin
-      return RM_Size (E) /= No_Uint
+      return Present (RM_Size (E))
         and then (RM_Size (E) /= Uint_0
                     or else Is_Discrete_Type (E)
                     or else Is_Fixed_Point_Type (E));
@@ -506,7 +506,7 @@ package body Einfo.Utils is
       pragma Assert
         (not Known_Esize (Id) or else Esize (Id) = V);
       pragma Assert
-        (RM_Size (Id) = No_Uint
+        (No (RM_Size (Id))
            or else RM_Size (Id) = Uint_0
            or else RM_Size (Id) = V);
       Set_Esize (Id, UI_From_Int (V));
index 00bd8c0e985dbdc96606d4183c582f6c38d587d1..88303c9f5055b24fd316b06f6a22f87ef55723cc 100644 (file)
@@ -504,7 +504,7 @@ package body Exp_Aggr is
       --  Scalar types are OK if their size is a multiple of Storage_Unit
 
       elsif Is_Scalar_Type (Ctyp) then
-         pragma Assert (Csiz /= No_Uint);
+         pragma Assert (Present (Csiz));
 
          if Csiz mod System_Storage_Unit /= 0 then
             return False;
index e86cb8f028fe3231916fc6fcf070a39f483ee9ad..4af8cf4f32fd8c96aca3786336409bf0fc528d9b 100644 (file)
@@ -8043,7 +8043,7 @@ package body Exp_Attr is
 
       --  Common processing for record and array component case
 
-      if Siz /= No_Uint and then Siz /= 0 then
+      if Present (Siz) and then Siz /= 0 then
          declare
             CS : constant Boolean := Comes_From_Source (N);
 
index ad82e568609720610de25e538e441a8b7081bb12..15882807f3e442d9a0d05a87f15ad666ee4c82cb 100644 (file)
@@ -8506,7 +8506,7 @@ package body Exp_Ch3 is
             if Compile_Time_Known_Value (Lo) then
                Lo_Val := Expr_Value (Lo);
 
-               if Lo_Bound = No_Uint or else Lo_Bound < Lo_Val then
+               if No (Lo_Bound) or else Lo_Bound < Lo_Val then
                   Lo_Bound := Lo_Val;
                end if;
             end if;
@@ -8514,7 +8514,7 @@ package body Exp_Ch3 is
             if Compile_Time_Known_Value (Hi) then
                Hi_Val := Expr_Value (Hi);
 
-               if Hi_Bound = No_Uint or else Hi_Bound > Hi_Val then
+               if No (Hi_Bound) or else Hi_Bound > Hi_Val then
                   Hi_Bound := Hi_Val;
                end if;
             end if;
@@ -8643,7 +8643,7 @@ package body Exp_Ch3 is
          --  If zero is invalid, it is a convenient value to use that is for
          --  sure an appropriate invalid value in all situations.
 
-         elsif Lo_Bound /= No_Uint and then Lo_Bound > Uint_0 then
+         elsif Present (Lo_Bound) and then Lo_Bound > Uint_0 then
             return Make_Integer_Literal (Loc, 0);
 
          --  Unsigned types
@@ -8702,7 +8702,7 @@ package body Exp_Ch3 is
          --  If zero is invalid, it is a convenient value to use that is for
          --  sure an appropriate invalid value in all situations.
 
-         if Lo_Bound /= No_Uint and then Lo_Bound > Uint_0 then
+         if Present (Lo_Bound) and then Lo_Bound > Uint_0 then
             Expr := Make_Integer_Literal (Loc, 0);
 
          --  Cases where all one bits is the appropriate invalid value
@@ -8741,7 +8741,7 @@ package body Exp_Ch3 is
 
             --  For this exceptional case, use largest positive value
 
-            if Lo_Bound /= No_Uint and then Hi_Bound /= No_Uint
+            if Present (Lo_Bound) and then Present (Hi_Bound)
               and then Lo_Bound <= (-(2 ** Signed_Size))
               and then Hi_Bound < 2 ** Signed_Size
             then
@@ -8811,7 +8811,7 @@ package body Exp_Ch3 is
          --  Determine the size of the object. This is either the size provided
          --  by the caller, or the Esize of the scalar type.
 
-         if Size = No_Uint or else Size <= Uint_0 then
+         if No (Size) or else Size <= Uint_0 then
             Size_To_Use := UI_Max (Uint_1, Esize (Typ));
          else
             Size_To_Use := Size;
@@ -8821,7 +8821,7 @@ package body Exp_Ch3 is
          --  will create values of type Long_Long_Long_Unsigned and the range
          --  must fit this type.
 
-         if Size_To_Use /= No_Uint
+         if Present (Size_To_Use)
            and then Size_To_Use > System_Max_Integer_Size
          then
             Size_To_Use := UI_From_Int (System_Max_Integer_Size);
index c52ec35d3eaa8cbfcd4785e4fa7ee419d2eaf8eb..cf9899d76c800fa6fdb5ff6ddabb4c11f6af9bc8 100644 (file)
@@ -2294,7 +2294,7 @@ package body Exp_Ch4 is
       --  We can only do this if we in fact have full range information (which
       --  won't be the case if either operand is bignum at this stage).
 
-      if Llo /= No_Uint and then Rlo /= No_Uint then
+      if Present (Llo) and then Present (Rlo) then
          case N_Op_Compare (Nkind (N)) is
             when N_Op_Eq =>
                if Llo = Lhi and then Rlo = Rhi and then Llo = Rlo then
index bfc3b3356f11c3fc11b3877345d8ea36f4c22848..a3751691f2820f0c08610c78568647cc24cbe4ec 100644 (file)
@@ -438,7 +438,7 @@ package body Exp_Dbug is
                     Enable
                       or else Is_Packed
                                 (Underlying_Type (Etype (Prefix (Ren))))
-                      or else (First_Bit /= No_Uint
+                      or else (Present (First_Bit)
                                 and then First_Bit /= Uint_0);
                end;
 
index 079cd441ebba699e9a5d7e4094807afab8008ab8..bac64928c574bb3f5d032f7a93c3195831c1cb29 100644 (file)
@@ -577,7 +577,7 @@ package body Exp_Disp is
          --  If number of primitives already set in the tag component, use it
 
          if Present (Tag_Comp)
-           and then DT_Entry_Count (Tag_Comp) /= No_Uint
+           and then Present (DT_Entry_Count (Tag_Comp))
          then
             return UI_To_Int (DT_Entry_Count (Tag_Comp));
 
@@ -8008,14 +8008,14 @@ package body Exp_Disp is
                          (Find_Dispatching_Type (Interface_Alias (Prim)), Typ,
                           Use_Full_View => True)
             then
-               pragma Assert (DT_Position (Prim) = No_Uint
-                 and then Present (DTC_Entity (Interface_Alias (Prim))));
+               pragma Assert (No (DT_Position (Prim)));
+               pragma Assert (Present (DTC_Entity (Interface_Alias (Prim))));
 
                E := Interface_Alias (Prim);
                Set_DT_Position_Value (Prim, DT_Position (E));
 
                pragma Assert
-                 (DT_Position (Alias (Prim)) = No_Uint
+                 (No (DT_Position (Alias (Prim)))
                     or else DT_Position (Alias (Prim)) = DT_Position (E));
                Set_DT_Position_Value (Alias (Prim), DT_Position (E));
                Set_Fixed_Prim (UI_To_Int (DT_Position (Prim)));
@@ -8066,7 +8066,7 @@ package body Exp_Disp is
 
             --  Skip primitives previously set entries
 
-            if DT_Position (Prim) /= No_Uint then
+            if Present (DT_Position (Prim)) then
                null;
 
             --  Primitives covering interface primitives are handled later
@@ -8099,7 +8099,7 @@ package body Exp_Disp is
       while Present (Prim_Elmt) loop
          Prim := Node (Prim_Elmt);
 
-         if DT_Position (Prim) = No_Uint
+         if No (DT_Position (Prim))
            and then Present (Interface_Alias (Prim))
          then
             pragma Assert (Present (Alias (Prim))
@@ -8111,14 +8111,14 @@ package body Exp_Disp is
                  (Find_Dispatching_Type (Interface_Alias (Prim)), Typ,
                   Use_Full_View => True)
             then
-               pragma Assert (DT_Position (Alias (Prim)) /= No_Uint);
+               pragma Assert (Present (DT_Position (Alias (Prim))));
                Set_DT_Position_Value (Prim, DT_Position (Alias (Prim)));
 
             --  Otherwise it will be placed in the secondary DT
 
             else
                pragma Assert
-                 (DT_Position (Interface_Alias (Prim)) /= No_Uint);
+                 (Present (DT_Position (Interface_Alias (Prim))));
                Set_DT_Position_Value (Prim,
                  DT_Position (Interface_Alias (Prim)));
             end if;
@@ -8147,7 +8147,7 @@ package body Exp_Disp is
          --  At this point all the primitives MUST have a position in the
          --  dispatch table.
 
-         if DT_Position (Prim) = No_Uint then
+         if No (DT_Position (Prim)) then
             raise Program_Error;
          end if;
 
@@ -8767,7 +8767,7 @@ package body Exp_Disp is
          --  (primary or secondary) dispatch table.
 
          if Present (DTC_Entity (Prim))
-           and then DT_Position (Prim) /= No_Uint
+           and then Present (DT_Position (Prim))
          then
             Write_Str (" at #");
             Write_Int (UI_To_Int (DT_Position (Prim)));
index 4b7615aab87e661316d34a3567c3ad66ef02c259..2802169603a50720469f0e2ad31f5901cb110f98 100644 (file)
@@ -13129,11 +13129,11 @@ package body Exp_Util is
                                            (Component_Type (Ityp))));
       end if;
 
-      if Ialign /= No_Uint and then Ialign > Maximum_Alignment then
+      if Present (Ialign) and then Ialign > Maximum_Alignment then
          return True;
 
-      elsif Ialign /= No_Uint
-        and then Oalign /= No_Uint
+      elsif Present (Ialign)
+        and then Present (Oalign)
         and then Ialign <= Oalign
       then
          return True;
index 5d850407ba291d4304666d2a32c4b2d49ff1d55e..7e250a4e2a1f527c00e487102e8d85b8a7254051 100644 (file)
@@ -776,7 +776,7 @@ package body Repinfo.Input is
             --  Compute Component_Bit_Offset from Position and First_Bit,
             --  either symbolically or literally depending on Position.
 
-            if Position = No_Uint or else First_Bit = No_Uint then
+            if No (Position) or else No (First_Bit) then
                Error ("bit offset expected");
             end if;
 
index 11e35e778388a85f39610e200b2b693ea3feca6a..ce42290e5efc6e6fc47c0f4c8494c98032be5f5d 100644 (file)
@@ -808,7 +808,7 @@ package body Repinfo is
    --  Start of processing for List_GCC_Expression
 
    begin
-      if U = No_Uint then
+      if No (U) then
          Write_Unknown_Val;
       else
          Print_Expr (U);
@@ -2117,7 +2117,7 @@ package body Repinfo is
 
    function Rep_Not_Constant (Val : Node_Ref_Or_Val) return Boolean is
    begin
-      if Val = No_Uint or else Val < 0 then
+      if No (Val) or else Val < 0 then
          return True;
       else
          return False;
@@ -2316,7 +2316,7 @@ package body Repinfo is
    --  Start of processing for Rep_Value
 
    begin
-      if Val = No_Uint then
+      if No (Val) then
          return No_Uint;
 
       else
@@ -2402,7 +2402,7 @@ package body Repinfo is
    procedure Write_Val (Val : Node_Ref_Or_Val; Paren : Boolean := False) is
    begin
       if Rep_Not_Constant (Val) then
-         if List_Representation_Info < 3 or else Val = No_Uint then
+         if List_Representation_Info < 3 or else No (Val) then
             Write_Unknown_Val;
 
          else
index ad5327911957d04e3a03ed87fbca4bca0bf1dfb3..e81985f0404c2074d33d8d2ab5c9f9cc3fbd46f1 100644 (file)
@@ -159,7 +159,7 @@ package body Scn is
             --  Int_Literal_Value can be No_Uint in some cases in syntax-only
             --  mode (see Scng.Scan.Nlit).
 
-            if Int_Literal_Value /= No_Uint then
+            if Present (Int_Literal_Value) then
                Set_Intval (Token_Node, Int_Literal_Value);
             end if;
 
index e37b61a4b4d4a6bacd0c40df0043a1d6c74ed7c7..9540089bac8ed3198db5947743b7ccaa90157f32 100644 (file)
@@ -9189,7 +9189,7 @@ package body Sem_Attr is
                   Fold_Uint (N, Uint_0, Static);
 
                when LT =>
-                  if Diff /= No_Uint then
+                  if Present (Diff) then
                      Fold_Uint (N, Diff + 1, Static);
                   end if;
 
@@ -9710,7 +9710,7 @@ package body Sem_Attr is
                Fold_Uint (N, Uint_0, Static);
 
             when LT =>
-               if Diff /= No_Uint then
+               if Present (Diff) then
                   Fold_Uint (N, Diff + 1, Static);
                end if;
 
index 0fe6c52da28f337396280abdcacd7d2a0e3d3408..0ac8bdccda4ff4c2d43577b3e8d2256f2800cfdb 100644 (file)
@@ -6631,7 +6631,7 @@ package body Sem_Ch13 is
             elsif Duplicate_Clause then
                null;
 
-            elsif Align /= No_Uint then
+            elsif Present (Align) then
                Set_Has_Alignment_Clause (U_Ent);
 
                --  Tagged type case, check for attempt to set alignment to a
@@ -6721,7 +6721,7 @@ package body Sem_Ch13 is
             elsif Rep_Item_Too_Early (Btype, N) then
                null;
 
-            elsif Csize /= No_Uint then
+            elsif Present (Csize) then
                Check_Size (Expr, Ctyp, Csize, Biased);
 
                --  For the biased case, build a declaration for a subtype that
@@ -7061,7 +7061,7 @@ package body Sem_Ch13 is
             elsif Duplicate_Clause then
                null;
 
-            elsif Radix /= No_Uint then
+            elsif Present (Radix) then
                Set_Has_Machine_Radix_Clause (U_Ent);
                Set_Has_Non_Standard_Rep (Base_Type (U_Ent));
 
@@ -7274,7 +7274,7 @@ package body Sem_Ch13 is
                Error_Msg_N
                  (Attr_Name & " cannot be given for unconstrained array", Nam);
 
-            elsif Size /= No_Uint then
+            elsif Present (Size) then
                declare
                   Etyp : constant Entity_Id :=
                     (if Is_Type (U_Ent) then U_Ent else Etype (U_Ent));
@@ -8106,7 +8106,7 @@ package body Sem_Ch13 is
             --  the list. The final checks for completeness and ordering are
             --  skipped in this case.
 
-            if Val = No_Uint then
+            if No (Val) then
                Err := True;
 
             elsif Val < Lo or else Hi < Val then
@@ -8185,7 +8185,7 @@ package body Sem_Ch13 is
                         Expr := Expression (Assoc);
                         Val := Static_Integer (Expr);
 
-                        if Val = No_Uint then
+                        if No (Val) then
                            Err := True;
 
                         elsif Val < Lo or else Hi < Val then
@@ -8220,12 +8220,12 @@ package body Sem_Ch13 is
             else
                Val := Enumeration_Rep (Elit);
 
-               if Min = No_Uint then
+               if No (Min) then
                   Min := Val;
                end if;
 
-               if Val /= No_Uint then
-                  if Max /= No_Uint and then Val <= Max then
+               if Present (Val) then
+                  if Present (Max) and then Val <= Max then
                      Error_Msg_NE
                        ("enumeration value for& not ordered!",
                         Enumeration_Rep_Expr (Elit), Elit);
@@ -8510,9 +8510,9 @@ package body Sem_Ch13 is
             Fbit  := Static_Integer (First_Bit (CC));
             Lbit  := Static_Integer (Last_Bit  (CC));
 
-            if Posit /= No_Uint
-              and then Fbit /= No_Uint
-              and then Lbit /= No_Uint
+            if Present (Posit)
+              and then Present (Fbit)
+              and then Present (Lbit)
             then
                if Posit < 0 then
                   Error_Msg_N ("position cannot be negative", Position (CC));
@@ -11943,7 +11943,7 @@ package body Sem_Ch13 is
                   begin
                      --  Skip components with unknown offsets
 
-                     if CBO /= No_Uint and then CBO >= 0 then
+                     if Present (CBO) and then CBO >= 0 then
                         Error_Msg_Uint_1 := CBO - Nbit;
 
                         if Warn and then Error_Msg_Uint_1 > 0 then
@@ -12058,7 +12058,7 @@ package body Sem_Ch13 is
             Pcomp := First_Entity (Tagged_Parent);
             while Present (Pcomp) loop
                if Ekind (Pcomp) in E_Discriminant | E_Component then
-                  if Component_Bit_Offset (Pcomp) /= No_Uint
+                  if Present (Component_Bit_Offset (Pcomp))
                     and then Known_Static_Esize (Pcomp)
                   then
                      Parent_Last_Bit :=
@@ -13127,7 +13127,7 @@ package body Sem_Ch13 is
       Align : constant Uint := Static_Integer (Expr);
 
    begin
-      if Align = No_Uint then
+      if No (Align) then
          return No_Uint;
 
       elsif Align < 0 then
@@ -16270,7 +16270,7 @@ package body Sem_Ch13 is
 
             elsif Nkind (N) = N_Selected_Component then
                Off := Component_Bit_Offset (Entity (Selector_Name (N)));
-               if Off /= No_Uint and then Off >= Uint_0 then
+               if Present (Off) and then Off >= Uint_0 then
                   Val := Val + Off;
                   N   := Prefix (N);
                else
@@ -16279,7 +16279,7 @@ package body Sem_Ch13 is
 
             elsif Nkind (N) = N_Indexed_Component then
                Off := Indexed_Component_Bit_Offset (N);
-               if Off /= No_Uint then
+               if Present (Off) then
                   Val := Val + Off;
                   N   := Prefix (N);
                else
index a3a286449094c9f788e31692bec07f1c1ac1e507..8817cea3d923ecb29175885251b9f9b7a05e25cd 100644 (file)
@@ -3069,7 +3069,7 @@ package body Sem_Eval is
             --  Note that in this case, both Right_Int and Left_Int are set
             --  to No_Uint, so need to test for both.
 
-            if Right_Int = No_Uint then
+            if No (Right_Int) then
                Fold_Uint (N, Uint_0, Stat);
             else
                Fold_Uint (N,
@@ -3083,7 +3083,7 @@ package body Sem_Eval is
             --  Note that in this case, both Right_Int and Left_Int are set
             --  to No_Uint, so need to test for both.
 
-            if Right_Int = No_Uint then
+            if No (Right_Int) then
                Fold_Uint (N, Uint_1, Stat);
             else
                Fold_Uint (N,
index a3d6ff81439bfe916640ebff62236f125503964c..6d53007e7904ddfa88ba1eb7a6dafdcb4c25799b 100644 (file)
@@ -11901,7 +11901,7 @@ package body Sem_Util is
 
                Check_Prefix;
                Offs := Indexed_Component_Bit_Offset (Expr);
-               if Offs = No_Uint then
+               if No (Offs) then
                   Offs := Component_Size (Typ);
                end if;
             end;
@@ -11932,7 +11932,7 @@ package body Sem_Util is
                else
                   --  If we have an offset, see if it is compatible
 
-                  if Offs /= No_Uint and Offs > Uint_0 then
+                  if Present (Offs) and Offs > Uint_0 then
                      if Offs mod (System_Storage_Unit * ObjA) /= 0 then
                         Set_Result (Known_Incompatible);
                      end if;
@@ -11961,7 +11961,7 @@ package body Sem_Util is
 
                   --  If we got an alignment, see if it is acceptable
 
-                  if ExpA /= No_Uint and then ExpA < ObjA then
+                  if Present (ExpA) and then ExpA < ObjA then
                      Set_Result (Known_Incompatible);
                   end if;
 
@@ -11969,7 +11969,7 @@ package body Sem_Util is
                   --  alignment, then we are fine. Otherwise, if its size is
                   --  known, it must be big enough for the required alignment.
 
-                  if Offs /= No_Uint then
+                  if Present (Offs) then
                      null;
 
                   --  See if Expr is an object with known size
@@ -11990,7 +11990,7 @@ package body Sem_Util is
                   --  acceptable, since the size is always a multiple of the
                   --  alignment.
 
-                  if SizA /= No_Uint then
+                  if Present (SizA) then
                      if SizA mod (ObjA * Ttypes.System_Storage_Unit) /= 0 then
                         Set_Result (Known_Incompatible);
                      end if;
@@ -12001,7 +12001,7 @@ package body Sem_Util is
          --  If we do not know required alignment, any non-zero offset is a
          --  potential problem (but certainly may be OK, so result is unknown).
 
-         elsif Offs /= No_Uint then
+         elsif Present (Offs) then
             Set_Result (Unknown);
 
          --  If we can't find the result by direct comparison of alignment
@@ -15044,7 +15044,7 @@ package body Sem_Util is
    begin
       --  Return early if the component size is not known or variable
 
-      if Off = No_Uint or else Off < Uint_0 then
+      if No (Off) or else Off < Uint_0 then
          return No_Uint;
       end if;
 
@@ -15567,7 +15567,7 @@ package body Sem_Util is
          --  Pragma Invalid_Scalars did not specify an invalid value for this
          --  type. Fall back to the value provided by the binder.
 
-         if Value = No_Uint then
+         if No (Value) then
             return Invalid_Binder_Value;
          else
             return Make_Integer_Literal (Loc, Intval => Value);
@@ -28271,7 +28271,7 @@ package body Sem_Util is
    begin
       --  Detect an attempt to set a different value for the same scalar type
 
-      pragma Assert (Slot = No_Uint);
+      pragma Assert (No (Slot));
       Slot := Value;
    end Set_Invalid_Scalar_Value;
 
index 7f9bb899989f0b77f5b442bd4646b54ecc83949a..083c12e8239ba6d4854a2f1a721e12386e9e89cd 100644 (file)
@@ -191,7 +191,7 @@ package body Sinfo.Utils is
    function End_Location (N : Node_Id) return Source_Ptr is
       L : constant Uint := End_Span (N);
    begin
-      if L = No_Uint then
+      if No (L) then
          return No_Location;
       else
          return Source_Ptr (Int (Sloc (N)) + UI_To_Int (L));
index 054d06ca76f6bd657ce99d2d73713601ca0b311f..48f76cb3664ff9198dec99c1d9463fae7fc6b8d0 100644 (file)
@@ -614,7 +614,7 @@ package body Treepr is
       Write_Str (UI_Image (Val));
       Write_Str (")  ");
 
-      if Val /= No_Uint then
+      if Present (Val) then
          Write_Location (End_Location (N));
       end if;
    end Print_End_Span;
index 8183469ca9bfa98e9eae78cbda2d3c4fbdd133b7..51af9b4448081559ba461497c85594fd1e4d3c45 100644 (file)
@@ -73,6 +73,18 @@ package body Uintp is
    --  These values are used in some cases where the use of numeric literals
    --  would cause ambiguities (integer vs Uint).
 
+   type UI_Vector is array (Pos range <>) of Int;
+   --  Vector containing the integer values of a Uint value
+
+   --  Note: An earlier version of this package used pointers of arrays of Ints
+   --  (dynamically allocated) for the Uint type. The change leads to a few
+   --  less natural idioms used throughout this code, but eliminates all uses
+   --  of the heap except for the table package itself. For example, Uint
+   --  parameters are often converted to UI_Vectors for internal manipulation.
+   --  This is done by creating the local UI_Vector using the function N_Digits
+   --  on the Uint to find the size needed for the vector, and then calling
+   --  Init_Operand to copy the values out of the table into the vector.
+
    ----------------------------
    -- UI_From_Int Hash Table --
    ----------------------------
@@ -127,6 +139,22 @@ package body Uintp is
    --  contain the corresponding one or two digit value. The low bound of Vec
    --  is always 1.
 
+   function Vector_To_Uint
+     (In_Vec   : UI_Vector;
+      Negative : Boolean) return Uint;
+   --  Functions that calculate values in UI_Vectors, call this function to
+   --  create and return the Uint value. In_Vec contains the multiple precision
+   --  (Base) representation of a non-negative value. Leading zeroes are
+   --  permitted. Negative is set if the desired result is the negative of the
+   --  given value. The result will be either the appropriate directly
+   --  represented value, or a table entry in the proper canonical format is
+   --  created and returned.
+   --
+   --  Note that Init_Operand puts a signed value in the result vector, but
+   --  Vector_To_Uint is always presented with a non-negative value. The
+   --  processing of signs is something that is done by the caller before
+   --  calling Vector_To_Uint.
+
    function Least_Sig_Digit (Arg : Uint) return Int;
    pragma Inline (Least_Sig_Digit);
    --  Returns the Least Significant Digit of Arg quickly. When the given Uint
@@ -361,7 +389,7 @@ package body Uintp is
    --  Start of processing for Image_Out
 
    begin
-      if Input = No_Uint then
+      if No (Input) then
          Image_Char ('?');
          return;
       end if;
@@ -1404,7 +1432,7 @@ package body Uintp is
 
       U := UI_Ints.Get (Input);
 
-      if U /= No_Uint then
+      if Present (U) then
          return U;
       end if;
 
@@ -2183,9 +2211,7 @@ package body Uintp is
    -- UI_To_Int --
    ---------------
 
-   function UI_To_Int (Input : Uint) return Int is
-      pragma Assert (Input /= No_Uint);
-
+   function UI_To_Int (Input : Valid_Uint) return Int is
    begin
       if Direct (Input) then
          return Direct_Val (Input);
@@ -2234,9 +2260,7 @@ package body Uintp is
    -- UI_To_Uns64 --
    -----------------
 
-   function UI_To_Unsigned_64 (Input : Uint) return Unsigned_64 is
-      pragma Assert (Input /= No_Uint);
-
+   function UI_To_Unsigned_64 (Input : Valid_Uint) return Unsigned_64 is
    begin
       if Input < Uint_0 then
          raise Constraint_Error;
index 70caf490f75019345b451b78099d897960280397..eb7137c6384af044becb52dbb97fb9d07a8fa7f2 100644 (file)
@@ -90,22 +90,13 @@ package Uintp is
    Uint_Minus_127 : constant Uint;
    Uint_Minus_128 : constant Uint;
 
-   subtype Valid_Uint is Uint with Predicate => Valid_Uint /= No_Uint;
-   subtype Unat is Valid_Uint with Predicate => Unat >= Uint_0;
-   subtype Upos is Valid_Uint with Predicate => Upos >= Uint_1;
-   subtype Nonzero_Uint is Valid_Uint with Predicate => Nonzero_Uint /= Uint_0;
-
-   type UI_Vector is array (Pos range <>) of Int;
-   --  Vector containing the integer values of a Uint value
+   function No (X : Uint) return Boolean is (X = No_Uint);
+   function Present (X : Uint) return Boolean is (not No (X));
 
-   --  Note: An earlier version of this package used pointers of arrays of Ints
-   --  (dynamically allocated) for the Uint type. The change leads to a few
-   --  less natural idioms used throughout this code, but eliminates all uses
-   --  of the heap except for the table package itself. For example, Uint
-   --  parameters are often converted to UI_Vectors for internal manipulation.
-   --  This is done by creating the local UI_Vector using the function N_Digits
-   --  on the Uint to find the size needed for the vector, and then calling
-   --  Init_Operand to copy the values out of the table into the vector.
+   subtype Valid_Uint is Uint with Predicate => Present (Valid_Uint);
+   subtype Unat is Valid_Uint with Predicate => Unat >= Uint_0; -- natural
+   subtype Upos is Valid_Uint with Predicate => Upos >= Uint_1; -- positive
+   subtype Nonzero_Uint is Valid_Uint with Predicate => Nonzero_Uint /= Uint_0;
 
    -----------------
    -- Subprograms --
@@ -253,12 +244,12 @@ package Uintp is
    function UI_From_CC (Input : Char_Code) return Uint;
    --  Converts Char_Code value to universal integer form
 
-   function UI_To_Int (Input : Uint) return Int;
+   function UI_To_Int (Input : Valid_Uint) return Int;
    --  Converts universal integer value to Int. Constraint_Error if value is
    --  not in appropriate range.
 
    type Unsigned_64 is mod 2**64;
-   function UI_To_Unsigned_64 (Input : Uint) return Unsigned_64;
+   function UI_To_Unsigned_64 (Input : Valid_Uint) return Unsigned_64;
    --  Converts universal integer value to Unsigned_64. Constraint_Error if
    --  value is not in appropriate range.
 
@@ -271,22 +262,6 @@ package Uintp is
    --  function is used for capacity checks, and it can be one bit off
    --  without affecting its usage.
 
-   function Vector_To_Uint
-     (In_Vec   : UI_Vector;
-      Negative : Boolean) return Uint;
-   --  Functions that calculate values in UI_Vectors, call this function to
-   --  create and return the Uint value. In_Vec contains the multiple precision
-   --  (Base) representation of a non-negative value. Leading zeroes are
-   --  permitted. Negative is set if the desired result is the negative of the
-   --  given value. The result will be either the appropriate directly
-   --  represented value, or a table entry in the proper canonical format is
-   --  created and returned.
-   --
-   --  Note that Init_Operand puts a signed value in the result vector, but
-   --  Vector_To_Uint is always presented with a non-negative value. The
-   --  processing of signs is something that is done by the caller before
-   --  calling Vector_To_Uint.
-
    ---------------------
    -- Output Routines --
    ---------------------
@@ -537,8 +512,9 @@ private
    --  Some subprograms defined in this package manipulate the Udigits table
    --  directly, while for others it is more convenient to work with locally
    --  defined arrays of the digits of the Universal Integers. The type
-   --  UI_Vector is defined for this purpose and some internal subprograms
-   --  used for converting from one to the other are defined.
+   --  UI_Vector is declared in the package body for this purpose and some
+   --  internal subprograms used for converting from one to the other are
+   --  defined.
 
    type Uint_Entry is record
       Length : aliased Pos;