From: Eric Botcazou <[email protected]>
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.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/sem_util.adb | 34 ++++++++++------------------------
gcc/ada/sem_util.ads | 4 ++--
2 files changed, 12 insertions(+), 26 deletions(-)
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index fb587ee0919..f8f18d3d48b 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);
-
- when others =>
- Pref := Empty;
- exit;
- end case;
- end loop;
-
- if Present (Pref) then
+ if Nkind (N) in N_Indexed_Component | N_Selected_Component then
+ Pref := Prefix (N);
Btyp := Base_Type (Etype (Pref));
- end if;
- return Present (Btyp)
- and then (Is_Record_Type (Btyp) or else Is_Array_Type (Btyp))
- and then Reverse_Storage_Order (Btyp);
+ return Present (Btyp)
+ and then (Is_Record_Type (Btyp) or else Is_Array_Type (Btyp))
+ and then Reverse_Storage_Order (Btyp);
+
+ else
+ return False;
+ end if;
end In_Reverse_Storage_Order_Object;
------------------------------
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
index e3349a1b595..46987bcc469 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;
--
2.53.0