public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1879] [Ada] tech debt: clean up Component_Size
@ 2021-06-29 14:24 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-06-29 14:24 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b9ec951f4318f1ed8d8c8d5477eeb534ad0811ae
commit r12-1879-gb9ec951f4318f1ed8d8c8d5477eeb534ad0811ae
Author: Bob Duff <duff@adacore.com>
Date: Fri Apr 9 08:56:23 2021 -0400
[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.
Diff:
---
gcc/ada/einfo-utils.adb | 10 ++++------
gcc/ada/einfo.ads | 7 ++++---
gcc/ada/sem_ch13.adb | 4 ----
gcc/ada/sem_ch13.ads | 3 +--
4 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb
index 0641862b73c..02ccef10f44 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 4c5a2daa2f7..5298998eba5 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 cfcbe148498..76dac2c424f 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 3869f92e53c..757981273dc 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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-29 14:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-29 14:24 [gcc r12-1879] [Ada] tech debt: clean up Component_Size Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).