[Ada] Missing accessibility error on object in type conversion
authorJustin Squirek <squirek@adacore.com>
Thu, 19 Mar 2020 20:59:30 +0000 (16:59 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 12 Jun 2020 08:29:10 +0000 (04:29 -0400)
2020-06-12  Justin Squirek  <squirek@adacore.com>

gcc/ada/

* sem_util.adb (Object_Access_Level): Add processing of implicit
dereferences.

gcc/ada/sem_util.adb

index 207d9d2..3ae8264 100644 (file)
@@ -23697,12 +23697,23 @@ package body Sem_Util is
       --  Local variables
 
       E        : Entity_Id;
-      Orig_Obj : constant Node_Id := Original_Node (Obj);
+      Orig_Obj : Node_Id := Original_Node (Obj);
       Orig_Pre : Node_Id;
 
    --  Start of processing for Object_Access_Level
 
    begin
+      --  In the case of an expanded implicit dereference we swap the original
+      --  object to be the expanded conversion.
+
+      if Nkind (Obj) = N_Explicit_Dereference
+        and then Nkind (Orig_Obj) /= N_Explicit_Dereference
+      then
+         Orig_Obj := Obj;
+      end if;
+
+      --  Calculate the object node's accessibility level
+
       if Nkind (Orig_Obj) = N_Defining_Identifier
         or else Is_Entity_Name (Orig_Obj)
       then