aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2021-04-09 08:56:23 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2021-06-29 14:23:46 +0000
commitb9ec951f4318f1ed8d8c8d5477eeb534ad0811ae (patch)
tree58fa06ddc61436c57a776eb3099bb86f7f000149
parent0bc7cf47c1266f9ae510c70833b5691c693c769f (diff)
downloadgcc-b9ec951f4318f1ed8d8c8d5477eeb534ad0811ae.zip
gcc-b9ec951f4318f1ed8d8c8d5477eeb534ad0811ae.tar.gz
gcc-b9ec951f4318f1ed8d8c8d5477eeb534ad0811ae.tar.bz2
[Ada] tech debt: clean up Component_Size
gcc/ada/ * einfo.ads (Component_Bit_Offset, Component_Size): Update documentation: Repinfo is the package where these negative values are documented. * einfo-utils.adb (Known_Component_Size, Known_Static_Component_Size, Unknown_Component_Size): Remove calls to Implementation_Base_Type, because Component_Size is an Impl_Base_Type_Only field (see Gen_Entities). * sem_ch13.ads, sem_ch13.adb (Check_Size): Do not set Esize and RM_Size. This is unnecessary in the case of Size. For Component_Size, it is wrong, because we would be setting the Esize and RM_Size of the component type.
-rw-r--r--gcc/ada/einfo-utils.adb10
-rw-r--r--gcc/ada/einfo.ads7
-rw-r--r--gcc/ada/sem_ch13.adb4
-rw-r--r--gcc/ada/sem_ch13.ads3
4 files changed, 9 insertions, 15 deletions
diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb
index 0641862..02ccef1 100644
--- a/gcc/ada/einfo-utils.adb
+++ b/gcc/ada/einfo-utils.adb
@@ -515,8 +515,8 @@ package body Einfo.Utils is
function Known_Component_Size (E : Entity_Id) return B is
begin
- return Component_Size (Implementation_Base_Type (E)) /= Uint_0
- and then Component_Size (Implementation_Base_Type (E)) /= No_Uint;
+ return Component_Size (E) /= Uint_0
+ and then Component_Size (E) /= No_Uint;
end Known_Component_Size;
function Known_Esize (E : Entity_Id) return B is
@@ -556,7 +556,7 @@ package body Einfo.Utils is
function Known_Static_Component_Size (E : Entity_Id) return B is
begin
- return Component_Size (Implementation_Base_Type (E)) > Uint_0;
+ return Component_Size (E) > Uint_0;
end Known_Static_Component_Size;
function Known_Static_Esize (E : Entity_Id) return B is
@@ -604,9 +604,7 @@ package body Einfo.Utils is
function Unknown_Component_Size (E : Entity_Id) return B is
begin
- return Component_Size (Implementation_Base_Type (E)) = Uint_0
- or else
- Component_Size (Implementation_Base_Type (E)) = No_Uint;
+ return not Known_Component_Size (E);
end Unknown_Component_Size;
function Unknown_Esize (E : Entity_Id) return B is
diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads
index 4c5a2da..5298998 100644
--- a/gcc/ada/einfo.ads
+++ b/gcc/ada/einfo.ads
@@ -669,7 +669,7 @@ package Einfo is
-- this field is always set. A negative value is used to represent
-- a value which is not known at compile time, and must be computed
-- at run-time (this happens if fields of a record have variable
--- lengths). See package Layout for details of these values.
+-- lengths). See package Repinfo for details of these values.
--
-- Note: Component_Bit_Offset is redundant with respect to the fields
-- Normalized_First_Bit and Normalized_Position, and could in principle
@@ -691,8 +691,9 @@ package Einfo is
-- by the front end in package Layout, or by the backend. A negative
-- value is used to represent a value which is not known at compile
-- time, and must be computed at run-time (this happens if the type
--- of the component has a variable length size). See package Layout
--- for details of these values.
+-- of the component has a variable length size). See package Repinfo
+-- for details of these values. Component_Size can also be negative in
+-- an illegal program that says e.g. "for T'Component_Size use -8;".
-- Component_Type [implementation base type only]
-- Defined in array types and string types. References component type.
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index cfcbe14..76dac2c 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -12479,8 +12479,6 @@ package body Sem_Ch13 is
else
Size_Too_Small_Error (Asiz);
- Set_Esize (T, Asiz);
- Set_RM_Size (T, Asiz);
end if;
end;
@@ -12518,8 +12516,6 @@ package body Sem_Ch13 is
if Siz < M then
Size_Too_Small_Error (M);
- Set_Esize (T, M);
- Set_RM_Size (T, M);
else
Biased := True;
end if;
diff --git a/gcc/ada/sem_ch13.ads b/gcc/ada/sem_ch13.ads
index 3869f92..7579812 100644
--- a/gcc/ada/sem_ch13.ads
+++ b/gcc/ada/sem_ch13.ads
@@ -125,8 +125,7 @@ package Sem_Ch13 is
-- set if the type is not currently biased, but biasing it is the only
-- way to meet the requirement. If the type is currently biased, then
-- this biased size is used in the initial check, and Biased is False.
- -- If the size is too small, and an error message is given, then both
- -- Esize and RM_Size are reset to the allowed minimum value in T.
+ -- For a Component_Size clause, T is the component type.
function Has_Compatible_Representation
(Target_Type, Operand_Type : Entity_Id) return Boolean;