aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/einfo-utils.adb
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2021-10-06 09:03:53 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2021-10-20 10:17:04 +0000
commit36e38022125f2f336e5d281fb3e5e66191d21e73 (patch)
tree568b72492d067a5dca44147b9e452dbba8b8136f /gcc/ada/einfo-utils.adb
parent749e01a5f310f2c4327f030d425aa6e23afbbbd5 (diff)
downloadgcc-36e38022125f2f336e5d281fb3e5e66191d21e73.zip
gcc-36e38022125f2f336e5d281fb3e5e66191d21e73.tar.gz
gcc-36e38022125f2f336e5d281fb3e5e66191d21e73.tar.bz2
[Ada] tech debt: Clean up Uint fields, such as Esize
gcc/ada/ * atree.ads: Comment improvements. How is a "completely new node" different from a "new node"? Document default values corresponding to field types. * exp_ch7.adb (Process_Tagged_Type_Declaration): Use higher-level Scope_Depth instead of Scope_Depth_Value. Remove confusing comment: not clear what a "true" library level package is. * uintp.adb (Image_Out): Print No_Uint in a more readable way. * gen_il-gen.adb, gen_il-gen-gen_entities.adb, gen_il-gen-gen_nodes.adb, gen_il-types.ads: Tighten up the subtypes of fields whose type is Uint, where possible; use more-constrained subtypes such as Unat. * einfo-utils.adb, einfo-utils.ads, exp_attr.adb, exp_ch3.adb, exp_intr.adb, exp_unst.adb, exp_util.adb, freeze.adb, repinfo.adb, sem.adb, sem_ch12.adb, sem_ch13.adb, sem_ch3.adb, sem_ch8.adb, sem_util.adb, sprint.adb, treepr.adb: No longer use Uint_0 to indicate "unknown" or "not yet known" for various fields whose type is Uint. Use No_Uint for that, except in a small number of legacy cases that cause test failures. Protect many queries of such fields with calls to Known_... functions. Improve comments. * exp_aggr.adb: Likewise. (Is_OK_Aggregate): Check whether Csiz is present. (Aggr_Assignment_OK_For_Backend): Ensure we do not access an uninitialized size. * exp_strm.adb (Build_Elementary_Input_Call, Build_Elementary_Write_Call): Check whether P_Size is present. * cstand.adb: Leave Component_Size of Any_Composite unknown. Similar for RM_Size of Standard_Exception_Type. These should not be used. * einfo.ads: Comment improvements. * exp_disp.ads: Minor. * gen_il-internals.ads, gen_il-internals.adb: Minor. * sinfo-utils.adb: Take advantage of full-coverage rules. * types.h: Minor.
Diffstat (limited to 'gcc/ada/einfo-utils.adb')
-rw-r--r--gcc/ada/einfo-utils.adb72
1 files changed, 24 insertions, 48 deletions
diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb
index 0274e6b..0c89c82 100644
--- a/gcc/ada/einfo-utils.adb
+++ b/gcc/ada/einfo-utils.adb
@@ -390,34 +390,23 @@ package body Einfo.Utils is
function Known_Static_Component_Bit_Offset (E : Entity_Id) return B is
begin
- return Present (Component_Bit_Offset (E))
+ return Known_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 Present (Component_Size (E));
+ return Present (Component_Size (E));
end Known_Component_Size;
function Known_Static_Component_Size (E : Entity_Id) return B is
begin
- return Component_Size (E) > Uint_0;
+ return Known_Component_Size (E) and then Component_Size (E) >= Uint_0;
end Known_Static_Component_Size;
- Use_New_Unknown_Rep : constant Boolean := False;
- -- If False, we represent "unknown" as Uint_0, which is wrong.
- -- We intend to make it True (and remove it), and represent
- -- "unknown" as Field_Is_Initial_Zero. We also need to change
- -- the type of Esize and RM_Size from Uint to Valid_Uint.
-
function Known_Esize (E : Entity_Id) return B is
begin
- if Use_New_Unknown_Rep then
- return not Field_Is_Initial_Zero (E, F_Esize);
- else
- return Present (Esize (E)) and then Esize (E) /= Uint_0;
- end if;
+ return Present (Esize (E));
end Known_Esize;
function Known_Static_Esize (E : Entity_Id) return B is
@@ -429,11 +418,7 @@ package body Einfo.Utils is
procedure Reinit_Esize (Id : E) is
begin
- if Use_New_Unknown_Rep then
- Reinit_Field_To_Zero (Id, F_Esize);
- else
- Set_Esize (Id, Uint_0);
- end if;
+ Reinit_Field_To_Zero (Id, F_Esize);
end Reinit_Esize;
procedure Copy_Esize (To, From : E) is
@@ -452,7 +437,7 @@ package body Einfo.Utils is
function Known_Static_Normalized_First_Bit (E : Entity_Id) return B is
begin
- return Present (Normalized_First_Bit (E))
+ return Known_Normalized_First_Bit (E)
and then Normalized_First_Bit (E) >= Uint_0;
end Known_Static_Normalized_First_Bit;
@@ -463,43 +448,25 @@ package body Einfo.Utils is
function Known_Static_Normalized_Position (E : Entity_Id) return B is
begin
- return Present (Normalized_Position (E))
+ return Known_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
- if Use_New_Unknown_Rep then
- return not Field_Is_Initial_Zero (E, F_RM_Size);
- else
- 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));
- end if;
+ return Present (RM_Size (E));
end Known_RM_Size;
function Known_Static_RM_Size (E : Entity_Id) return B is
begin
- if Use_New_Unknown_Rep then
- return Known_RM_Size (E)
- and then RM_Size (E) >= Uint_0
- and then not Is_Generic_Type (E);
- else
- return (RM_Size (E) > Uint_0
- or else Is_Discrete_Type (E)
- or else Is_Fixed_Point_Type (E))
- and then not Is_Generic_Type (E);
- end if;
+ return Known_RM_Size (E)
+ and then RM_Size (E) >= Uint_0
+ and then not Is_Generic_Type (E);
end Known_Static_RM_Size;
procedure Reinit_RM_Size (Id : E) is
begin
- if Use_New_Unknown_Rep then
- Reinit_Field_To_Zero (Id, F_RM_Size);
- else
- Set_RM_Size (Id, Uint_0);
- end if;
+ Reinit_Field_To_Zero (Id, F_RM_Size);
end Reinit_RM_Size;
procedure Copy_RM_Size (To, From : E) is
@@ -541,9 +508,8 @@ package body Einfo.Utils is
begin
pragma Assert (Is_Type (Id));
pragma Assert (not Known_Esize (Id) or else Esize (Id) = V);
- if Use_New_Unknown_Rep then
- pragma Assert (not Known_RM_Size (Id) or else RM_Size (Id) = V);
- end if;
+ pragma Assert (not Known_RM_Size (Id) or else RM_Size (Id) = V);
+
Set_Esize (Id, UI_From_Int (V));
Set_RM_Size (Id, UI_From_Int (V));
end Init_Size;
@@ -2593,6 +2559,16 @@ package body Einfo.Utils is
return Scope_Depth_Value (Scop);
end Scope_Depth;
+ function Scope_Depth_Default_0 (Id : E) return U is
+ begin
+ if Scope_Depth_Set (Id) then
+ return Scope_Depth (Id);
+
+ else
+ return Uint_0;
+ end if;
+ end Scope_Depth_Default_0;
+
---------------------
-- Scope_Depth_Set --
---------------------