[Ada] Consolidate handling of implicit dereferences into semantic analysis
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 16 Mar 2020 18:28:47 +0000 (19:28 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 11 Jun 2020 09:53:42 +0000 (05:53 -0400)
commitf715a5bd3fb6bb70c11b29dc2b54f2459ed36bfb
treeeec29227b0603a20d1cec4cf885710cc93b7b374
parentc7cb99f885d2d6d520ef8ff0ff35e0158f2c6264
[Ada] Consolidate handling of implicit dereferences into semantic analysis

2020-06-11  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* checks.adb (Build_Discriminant_Checks): Build an explicit
dereference when the type is an access type.
* exp_atag.adb (Build_CW_Membership): Add explicit dereferences.
(Build_Get_Access_Level): Likewise.
(Build_Get_Alignment): Likewise.
(Build_Inherit_Prims): Likewise.
(Build_Get_Transportable): Likewise.
(Build_Set_Size_Function): Likewise.
* exp_ch3.adb (Build_Offset_To_Top_Function): Likewise.
* exp_ch4.adb (Expand_Allocator_Expression): Likewise.
(Expand_N_Indexed_Component ): Remove code dealing with implicit
dereferences.
(Expand_N_Selected_Component): Likewise.
(Expand_N_Slice): Likewise.
* exp_ch9.adb (Add_Formal_Renamings): Add explicit dereference.
(Expand_Accept_Declarations): Likewise.
(Build_Simple_Entry_Call): Remove code dealing with implicit
dereferences.
(Expand_N_Requeue_Statement): Likewise.
* exp_disp.adb (Expand_Dispatching_Call): Build an explicit
dereference when the controlling type is an access type.
* exp_spark.adb (Expand_SPARK_N_Selected_Component): Delete.
(Expand_SPARK_N_Slice_Or_Indexed_Component): Likewise.
(Expand_SPARK): Do not call them.
* sem_ch4.adb (Process_Implicit_Dereference_Prefix): Delete.
(Process_Indexed_Component): Call Implicitly_Designated_Type
to get the designated type for an implicit dereference.
(Analyze_Overloaded_Selected_Component): Do not insert an
explicit dereference here.
(Analyze_Selected_Component): Likewise.
(Analyze_Slice): Call Implicitly_Designated_Type to get the
designated type for an implicit dereference.
* sem_ch8.adb (Has_Components): New predicate extracted from...
(Is_Appropriate_For_Record): ...this.  Delete.
(Is_Appropriate_For_Entry_Prefix): Likewise.
(Analyze_Renamed_Entry): Deal with implicit dereferences.
(Find_Selected_Component): Do not insert an explicit dereference
here.  Call Implicitly_Designated_Type to get the designated type
for an implicit dereference.  Call Has_Components, Is_Task_Type
and Is_Protected_Type directly.  Adjust test for error.
* sem_res.adb (Resolve_Implicit_Dereference): New procedure.
(Resolve_Call): Call Resolve_Indexed_Component last.
(Resolve_Entry): Call Resolve_Implicit_Dereference on the prefix.
(Resolve_Indexed_Component): Call Implicitly_Designated_Type to
get the designated type for an implicit dereference and
Resolve_Implicit_Dereference on the prefix at the end.
(Resolve_Selected_Component): Likewise.
(Resolve_Slice): Likewise.  Do not apply access checks here.
* sem_util.ads (Implicitly_Designated_Type): Declare.
* sem_util.adb (Copy_And_Maybe_Dereference): Simplify.
(Implicitly_Designated_Type): New function.
(Object_Access_Level): Fix typo.
* sem_warn.adb (Check_Unset_Reference): Test Comes_From_Source
on the original node.
13 files changed:
gcc/ada/checks.adb
gcc/ada/exp_atag.adb
gcc/ada/exp_ch3.adb
gcc/ada/exp_ch4.adb
gcc/ada/exp_ch9.adb
gcc/ada/exp_disp.adb
gcc/ada/exp_spark.adb
gcc/ada/sem_ch4.adb
gcc/ada/sem_ch8.adb
gcc/ada/sem_res.adb
gcc/ada/sem_util.adb
gcc/ada/sem_util.ads
gcc/ada/sem_warn.adb