[gcc r16-5378] ada: Don't generate function that violates No_Dynamic_Sized_Objects restriction
Marc Poulhies
dkm@gcc.gnu.org
Tue Nov 18 15:06:39 GMT 2025
https://gcc.gnu.org/g:6651ce055d40d0aab06a51f9cd5028478bb8d9b4
commit r16-5378-g6651ce055d40d0aab06a51f9cd5028478bb8d9b4
Author: Steve Baird <baird@adacore.com>
Date: Thu Oct 30 14:40:06 2025 -0700
ada: Don't generate function that violates No_Dynamic_Sized_Objects restriction
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.
Diff:
---
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 3fef6fabe64e..ea7b18582179 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
More information about the Gcc-cvs
mailing list