Subsequent to prior major cleanups of Uint fields, this patch includes a
few more, fairly minor, cleanups.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* freeze.adb (Freeze_Fixed_Point_Type): Remove
previously-inserted test for Uint_0; no longer needed.
* gen_il-gen.ads: Improve comments.
* repinfo.adb (Rep_Value): Use Ubool type for B.
* repinfo.ads (Node_Ref): Use Unegative type.
(Node_Ref_Or_Val): Document that values of this type can be
No_Uint.
* exp_disp.adb (Make_Disp_Requeue_Body): Minor comment fix.
* sem_ch3.adb: Likewise.
* sem_ch8.adb: Likewise.
* sinfo-utils.adb (End_Location): End_Span can never be No_Uint,
so remove the "if No (L)" test.
* uintp.adb (Image_String): Use "for ... of" loop.
* uintp.ads (Unegative): New type for negative integers. We
give it a long name (unlike Unat and Upos) because it is rarely
used.
diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb
--- a/gcc/ada/exp_disp.adb
+++ b/gcc/ada/exp_disp.adb
@@ -3037,7 +3037,7 @@ package body Exp_Disp is
begin
pragma Assert (not Restriction_Active (No_Dispatching_Calls));
- -- Null body is generated for interface types and non-concurrent
+ -- Null body is generated for interface types and nonconcurrent
-- tagged types.
if Is_Interface (Typ)
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -9500,9 +9500,7 @@ package body Freeze is
Minsiz : constant Uint := UI_From_Int (Minimum_Size (Typ));
begin
- if Known_RM_Size (Typ)
- and then RM_Size (Typ) /= Uint_0
- then
+ if Known_RM_Size (Typ) then
if RM_Size (Typ) < Minsiz then
Error_Msg_Uint_1 := RM_Size (Typ);
Error_Msg_Uint_2 := Minsiz;
diff --git a/gcc/ada/gen_il-gen.ads b/gcc/ada/gen_il-gen.ads
--- a/gcc/ada/gen_il-gen.ads
+++ b/gcc/ada/gen_il-gen.ads
@@ -204,9 +204,22 @@ package Gen_IL.Gen is
-- Gen_IL.Fields, and delete all occurrences from Gen_IL.Gen.Gen_Entities.
-- If a field is not set, it is initialized by default to whatever value is
- -- represented by all-zero bits, with two exceptions: Elist fields default
- -- to No_Elist, and Uint fields default to Uint_0. In retrospect, it would
- -- have been better to use No_Uint instead of Uint_0.
+ -- represented by all-zero bits, with some exceptions. This means Flags are
+ -- initialized to False, Node_Ids and List_Ids are initialized to Empty,
+ -- and enumeration fields are initialized to 'First of the type (assuming
+ -- there is no representation clause).
+ --
+ -- Elists default to No_Elist.
+ --
+ -- Fields of type Uint (but not its subtypes) are initialized to No_Uint.
+ -- Fields of subtypes Valid_Uint, Unat, Upos, Nonzero_Uint, and Ureal have
+ -- no default; it is an error to call a getter before calling the setter.
+ -- Likewise, other types whose range does not include zero have no default
+ -- (see package Types for the ranges).
+ --
+ -- If a node is created by a function in Nmake, then the defaults are
+ -- different from what is specified above. The parameters of Make_...
+ -- functions can have defaults specified; see Create_Syntactic_Field.
procedure Create_Node_Union_Type
(T : Abstract_Node; Children : Type_Array);
diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb
--- a/gcc/ada/repinfo.adb
+++ b/gcc/ada/repinfo.adb
@@ -2120,7 +2120,7 @@ package body Repinfo is
function Rep_Value (Val : Node_Ref_Or_Val; D : Discrim_List) return Uint is
- function B (Val : Boolean) return Uint;
+ function B (Val : Boolean) return Ubool;
-- Returns Uint_0 for False, Uint_1 for True
function T (Val : Node_Ref_Or_Val) return Boolean;
@@ -2141,7 +2141,7 @@ package body Repinfo is
-- B --
-------
- function B (Val : Boolean) return Uint is
+ function B (Val : Boolean) return Ubool is
begin
if Val then
return Uint_1;
diff --git a/gcc/ada/repinfo.ads b/gcc/ada/repinfo.ads
--- a/gcc/ada/repinfo.ads
+++ b/gcc/ada/repinfo.ads
@@ -118,12 +118,12 @@ package Repinfo is
-- this field is done only in -gnatR3 mode, and in other modes, the value
-- is set to Uint_Minus_1.
- subtype Node_Ref is Uint;
+ subtype Node_Ref is Unegative;
-- Subtype used for negative Uint values used to represent nodes
subtype Node_Ref_Or_Val is Uint;
- -- Subtype used for values that can either be a Node_Ref (negative)
- -- or a value (non-negative)
+ -- Subtype used for values that can be a Node_Ref (negative) or a value
+ -- (non-negative) or No_Uint.
type TCode is range 0 .. 27;
-- Type used on Ada side to represent DEFTREECODE values defined in
@@ -306,7 +306,7 @@ package Repinfo is
-- In the case of components, if the location of the component is static,
-- then all four fields (Component_Bit_Offset, Normalized_Position, Esize,
-- and Normalized_First_Bit) are set to appropriate values. In the case of
- -- a non-static component location, Component_Bit_Offset is not used and
+ -- a nonstatic component location, Component_Bit_Offset is not used and
-- is left set to Unknown. Normalized_Position and Normalized_First_Bit
-- are set appropriately.
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -21301,7 +21301,7 @@ package body Sem_Ch3 is
goto Leave;
end;
- -- For non-concurrent types, transfer explicit primitives, but
+ -- For nonconcurrent types, transfer explicit primitives, but
-- omit those inherited from the parent of the private view
-- since they will be re-inherited later on.
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -9236,7 +9236,7 @@ package body Sem_Ch8 is
if Ekind (S) = E_Void then
null;
- -- Set scope depth if not a non-concurrent type, and we have not yet set
+ -- Set scope depth if not a nonconcurrent type, and we have not yet set
-- the scope depth. This means that we have the first occurrence of the
-- scope, and this is where the depth is set.
diff --git a/gcc/ada/sinfo-utils.adb b/gcc/ada/sinfo-utils.adb
--- a/gcc/ada/sinfo-utils.adb
+++ b/gcc/ada/sinfo-utils.adb
@@ -189,13 +189,9 @@ package body Sinfo.Utils is
------------------
function End_Location (N : Node_Id) return Source_Ptr is
- L : constant Uint := End_Span (N);
+ L : constant Valid_Uint := End_Span (N);
begin
- if No (L) then
- return No_Location;
- else
- return Source_Ptr (Int (Sloc (N)) + UI_To_Int (L));
- end if;
+ return Source_Ptr (Int (Sloc (N)) + UI_To_Int (L));
end End_Location;
--------------------
diff --git a/gcc/ada/uintp.adb b/gcc/ada/uintp.adb
--- a/gcc/ada/uintp.adb
+++ b/gcc/ada/uintp.adb
@@ -380,8 +380,8 @@ package body Uintp is
procedure Image_String (S : String) is
begin
- for X in S'Range loop
- Image_Char (S (X));
+ for X of S loop
+ Image_Char (X);
end loop;
end Image_String;
diff --git a/gcc/ada/uintp.ads b/gcc/ada/uintp.ads
--- a/gcc/ada/uintp.ads
+++ b/gcc/ada/uintp.ads
@@ -104,6 +104,7 @@ package Uintp is
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;
+ subtype Unegative is Valid_Uint with Predicate => Unegative < Uint_0;
subtype Ubool is Valid_Uint with Predicate => Ubool in Uint_0 | Uint_1;
subtype Opt_Ubool is Uint with
Predicate => No (Opt_Ubool) or else Opt_Ubool in Ubool;