This consolidates the handling of almost all the implicit dereferences
allowed in Ada 95 into the semantic analysis phase of the compiler, and
more precisely in the Resolve routine of the front-end.

This both means that the generic code handling them in the expander
is removed, and that various constructs generated by it are directly
built with explicit dereferences when needed.

No functional changes, except for swapped error messages in case of
problematic dereferences in requeue statements.

Tested on x86_64-pc-linux-gnu, committed on trunk

2020-06-11  Eric Botcazou  <ebotca...@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.

Attachment: patch.diff.gz
Description: application/gzip

Reply via email to