From: Steve Baird <[email protected]>
In some cases, the compiler implicitly generates a hash function for an
enumeration type. If a No_Dynamic_Sized_Objects restriction is in effect then
that hash function violates the restriction, resulting in a compilation
failure. Therefore, do not generate the hash function in that case.
gcc/ada/ChangeLog:
* exp_imgv.adb (Build_Enumeration_Image_Tables): If a
No_Dynamic_Sized_Objects restriction is in effect, then choose a large
value for Threshold so that no Lit_Hash function is generated.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/exp_imgv.adb | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/gcc/ada/exp_imgv.adb b/gcc/ada/exp_imgv.adb
index 3fef6fabe64..ea7b1858217 100644
--- a/gcc/ada/exp_imgv.adb
+++ b/gcc/ada/exp_imgv.adb
@@ -112,13 +112,18 @@ package body Exp_Imgv is
-- exactly spent on all possible paths from this point.
Threshold : constant Nat :=
- (if Is_Library_Level_Entity (E)
+ (if Restriction_Active (No_Dynamic_Sized_Objects)
+ then Nat'Last
+ elsif Is_Library_Level_Entity (E)
or else not Always_Compatible_Rep_On_Target
then 3
else Nat'Last);
-- Threshold above which we want to generate the hash function in the
-- default case. We avoid doing it if this would cause a trampoline to
-- be generated because the type is local and descriptors are not used.
+ -- We also avoid doing it if a No_Dynamic_Sized_Objects restriction is
+ -- in effect because the hash function will violate the restriction
+ -- by declaring an array subtype with dynamic bounds.
Threshold_For_Size : constant Nat := Nat'Max (Threshold, 9);
-- But the function and its tables take a bit of space so the threshold
--
2.51.0