https://gcc.gnu.org/g:b0a85ce055ecb21afd4491b8d1a5da521a81a4bf
commit r16-9058-gb0a85ce055ecb21afd4491b8d1a5da521a81a4bf Author: Eric Botcazou <[email protected]> Date: Wed May 6 10:44:28 2026 +0200 ada: Fix bogus validity check failure for FP component of array with reverse SSO It comes from a thinko in Sem_Util.In_Reverse_Storage_Order_Object: only the innermost enclosing composite type needs to be considered by the predicate. gcc/ada/ChangeLog: * sem_util.ads (In_Reverse_Storage_Order_Object): Adjust. * sem_util.adb (In_Reverse_Storage_Order_Object): Rewrite. Diff: --- gcc/ada/sem_util.adb | 32 +++++++++----------------------- gcc/ada/sem_util.ads | 4 ++-- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index e28215f559eb..e564558c51e7 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -14924,34 +14924,20 @@ package body Sem_Util is function In_Reverse_Storage_Order_Object (N : Node_Id) return Boolean is Pref : Node_Id; - Btyp : Entity_Id := Empty; + Btyp : Entity_Id; begin - -- Climb up indexed components - - Pref := N; - loop - case Nkind (Pref) is - when N_Selected_Component => - Pref := Prefix (Pref); - exit; - - when N_Indexed_Component => - Pref := Prefix (Pref); + if Nkind (N) in N_Indexed_Component | N_Selected_Component then + Pref := Prefix (N); + Btyp := Base_Type (Etype (Pref)); - when others => - Pref := Empty; - exit; - end case; - end loop; + return Present (Btyp) + and then (Is_Record_Type (Btyp) or else Is_Array_Type (Btyp)) + and then Reverse_Storage_Order (Btyp); - if Present (Pref) then - Btyp := Base_Type (Etype (Pref)); + else + return False; end if; - - return Present (Btyp) - and then (Is_Record_Type (Btyp) or else Is_Array_Type (Btyp)) - and then Reverse_Storage_Order (Btyp); end In_Reverse_Storage_Order_Object; ------------------------------ diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index d8721e5dcd24..a74f658b9dce 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -1760,8 +1760,8 @@ package Sem_Util is -- result of the enclosing function. function In_Reverse_Storage_Order_Object (N : Node_Id) return Boolean; - -- Returns True if N denotes a component or subcomponent in a record or - -- array that has Reverse_Storage_Order. + -- Returns True if N denotes a component in an array or a record that has + -- Reverse_Storage_Order. function In_Same_Declarative_Part (Context : Node_Id;
