https://gcc.gnu.org/g:5d24c744d41f7b0cada458d5cde1a50d690d10f2
commit r16-6602-g5d24c744d41f7b0cada458d5cde1a50d690d10f2 Author: Ronan Desplanques <[email protected]> Date: Mon Nov 24 09:55:56 2025 +0100 ada: Allow component clauses for certain record components with discriminants Before this patch, the compiler rejected record representation clauses when a component has a subtype with a non-static discriminant constraint. This is a somewhat coarse-grained since the size of such a component can be constant relatively to the discriminant. One such case in particular is when the component subtype is an unchecked union. This patch makes the compiler accept the unchecked union case. gcc/ada/ChangeLog: * freeze.adb (Size_Known): Modify rejection condition. Diff: --- gcc/ada/freeze.adb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index fc39cc7b9da1..7f5a043cca9e 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -932,10 +932,15 @@ package body Freeze is elsif Is_Record_Type (T) then -- A subtype of a variant record must not have non-static - -- discriminated components. + -- discriminants that influence the size. We don't do all that we + -- could to determine whether a non-static discriminant value can + -- make the size vary, but we handle the special case of unchecked + -- unions where all objects have the same size (see RM B.3.3 + -- (14/2)). if T /= Base_Type (T) and then not Static_Discriminated_Components (T) + and then not Is_Unchecked_Union (T) then return False;
