diff options
author | Bob Duff <duff@adacore.com> | 2021-05-19 11:37:47 -0400 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-07-07 16:23:15 +0000 |
commit | a547eea2669af282dfca4f3c38362f109b285308 (patch) | |
tree | 5cc8c1078625afb15eaebc43737cdb63f4c7bfee /gcc/ada/einfo-utils.adb | |
parent | 2d71668e64c4b20aec823dbe5a1feb6338d527a2 (diff) | |
download | gcc-a547eea2669af282dfca4f3c38362f109b285308.zip gcc-a547eea2669af282dfca4f3c38362f109b285308.tar.gz gcc-a547eea2669af282dfca4f3c38362f109b285308.tar.bz2 |
[Ada] Fix bugs in Value_Size clauses and refactor
gcc/ada/
* sem_ch13.adb (Analyze_Attribute_Definition_Clause): Combine
processing of Size and Value_Size clauses. Ensure that
Value_Size is treated the same as Size, in the cases where both
are allowed (i.e. the prefix denotes a first subtype). Misc
cleanup.
* einfo-utils.adb (Init_Size): Add assertions.
(Size_Clause): Return a Value_Size clause if present, instead of
just looking for a Size clause.
* einfo.ads (Has_Size_Clause, Size_Clause): Change documentation
to include Value_Size.
* sem_ch13.ads, layout.ads, layout.adb: Comment modifications.
Diffstat (limited to 'gcc/ada/einfo-utils.adb')
-rw-r--r-- | gcc/ada/einfo-utils.adb | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb index 6e8a772..22143d6 100644 --- a/gcc/ada/einfo-utils.adb +++ b/gcc/ada/einfo-utils.adb @@ -481,7 +481,13 @@ package body Einfo.Utils is procedure Init_Size (Id : E; V : Int) is begin - pragma Assert (not Is_Object (Id)); + pragma Assert (Is_Type (Id)); + pragma Assert + (not Known_Esize (Id) or else Esize (Id) = V); + pragma Assert + (RM_Size (Id) = No_Uint + or else RM_Size (Id) = Uint_0 + or else RM_Size (Id) = V); Set_Esize (Id, UI_From_Int (V)); Set_RM_Size (Id, UI_From_Int (V)); end Init_Size; @@ -492,7 +498,7 @@ package body Einfo.Utils is procedure Init_Size_Align (Id : E) is begin - pragma Assert (not Is_Object (Id)); + pragma Assert (Ekind (Id) in Type_Kind | E_Void); Set_Esize (Id, Uint_0); Set_RM_Size (Id, Uint_0); Set_Alignment (Id, Uint_0); @@ -2927,8 +2933,13 @@ package body Einfo.Utils is ----------------- function Size_Clause (Id : E) return N is + Result : N := Get_Attribute_Definition_Clause (Id, Attribute_Size); begin - return Get_Attribute_Definition_Clause (Id, Attribute_Size); + if No (Result) then + Result := Get_Attribute_Definition_Clause (Id, Attribute_Value_Size); + end if; + + return Result; end Size_Clause; ------------------------ |