https://gcc.gnu.org/g:60f5887173a458008f1252323a6ea08ba0a85aab
commit r17-1295-g60f5887173a458008f1252323a6ea08ba0a85aab 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 fb587ee09191..f8f18d3d48bd 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -14885,34 +14885,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 e3349a1b595b..46987bcc469a 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -1756,8 +1756,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;
