GNAT's initial implementation of Ada 2022's Image and Put_Image
attributes did not include full support for tagged types. Improve that
level of support. This support is still disabled by default and is
enabled via the -gnatd_z switch because it generates additional
dispatching routines even for Ada 2022 programs that do not make
(explicit or implicit) use of the Image or Put_Image attributes of
tagged types.

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

gcc/ada/

        * debug.adb: Remove comments about -gnatd_z switch.
        * exp_ch3.adb (Make_Predefined_Primitive_Specs): A one-line fix
        for a subtle bug that took some effort to debug. Append a new
        Put_Image procedure for a type extension even if it seems to
        already have one, just as is done for (for example) the
        streaming-related Read procedure.
        * exp_put_image.adb:
        (Build_Record_Put_Image_Procedure.Make_Component_Attributes): Do
        not treat _Parent component like just another component, for two
        reasons.  1. If the _parent component's type has a
        user-specified Put_Image procedure, then we want to generate a
        call to that procedure and then generate extension aggregate
        syntax.  2. Otherwise, we still don't want to see any mention of
        "_parent" in the generated image text.
        (Build_Record_Put_Image_Procedure.Make_Component_Name): Add
        assertion that we are not generating a reference to an "_parent"
        component.
        (Build_Record_Put_Image_Procedure): Add special treatment for
        null records.  Add call to Duplicate_Subexpr for image attribute
        prefix in order to help with expansion needed in the class-wide
        case (where the prefix is also referenced in the call to
        Wide_Wide_Expanded_Name) if evaluation of the prefix has side
        effects. Add new local helper function, Put_String_Exp.  Add
        support for case where prefix type is class-wide.
        (Enable_Put_Image, Preload_Root_Buffer_Type): Query Ada_Version
        > Ada_2022 instead of (indirectly) querying -gnatd_z switch.
        * freeze.adb (In_Expanded_Body): A one-line change to add
        TSS_Put_Image to the list of subprograms that have
        expander-created bodies.
        * rtsfind.ads: Add support for accessing
        Ada.Tags.Wide_Wide_Expanded_Name.
        * sem_ch3.ads, sem_ch3.adb: Delete Is_Null_Extension function,
        as part of moving it to Sem_Util.
        * sem_ch13.adb
        (Analyze_Put_Image_TSS_Definition.Has_Good_Profile): Improve
        diagnostic messages in cases where the result is going to be
        False and the Report parameter is True. Relax overly-restrictive
        checks in order to implement mode conformance.
        (Analyze_Stream_TSS_Definition.Has_Good_Profile): Add similar
        relaxation of parameter subtype checking for the Stream
        parameter of user-defined streaming subprograms.
        * sem_disp.adb (Check_Dispatching_Operation): A one-line
        change (and an accompanying comment change) to add TSS_Put_Image
        to the list of compiler-generated dispatching primitive
        operations.
        * sem_util.ads, sem_util.adb: Add Ignore_Privacy Boolean
        parameter to Is_Null_Record_Type function (typically the
        parameter will be False when the function is being used in the
        implementation of static semantics and True for dynamic
        semantics; the parameter might make a difference in the case of,
        for example, a private type that is implemented as a null record
        type).  Add related new routines Is_Null_Extension (formerly
        declared in Sem_Ch3), Is_Null_Extension_Of, and
        Is_Null_Record_Definition.

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

Reply via email to