From: Bob Duff Date: Fri, 9 Apr 2021 12:56:23 +0000 (-0400) Subject: [Ada] tech debt: clean up Component_Size X-Git-Tag: basepoints/gcc-13~6434 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9ec951f4318f1ed8d8c8d5477eeb534ad0811ae;p=thirdparty%2Fgcc.git [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 --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb index 0641862b73ca..02ccef10f442 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 4c5a2daa2f76..5298998eba52 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 cfcbe1484988..76dac2c424fb 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 3869f92e53c7..757981273dc4 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;