aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_util.ads
diff options
context:
space:
mode:
authorSteve Baird <baird@adacore.com>2021-04-16 16:07:31 -0700
committerPierre-Marie de Rodat <derodat@adacore.com>2021-07-05 13:09:09 +0000
commitb4b023c4267801dce118923421124e0d9f65075f (patch)
treed090c11ee08f2d652f4bbbc7ba82a24aff438478 /gcc/ada/sem_util.ads
parentb9713be32ba408b1d8002d92c589c6c3ed8f8831 (diff)
downloadgcc-b4b023c4267801dce118923421124e0d9f65075f.zip
gcc-b4b023c4267801dce118923421124e0d9f65075f.tar.gz
gcc-b4b023c4267801dce118923421124e0d9f65075f.tar.bz2
[Ada] Add Ada 2022 Image and Put_Image support for tagged types
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.
Diffstat (limited to 'gcc/ada/sem_util.ads')
-rw-r--r--gcc/ada/sem_util.ads25
1 files changed, 22 insertions, 3 deletions
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
index 10f1ba5..0894d03 100644
--- a/gcc/ada/sem_util.ads
+++ b/gcc/ada/sem_util.ads
@@ -2126,9 +2126,28 @@ package Sem_Util is
-- assertion expression of pragma Default_Initial_Condition and if it does,
-- the encapsulated expression is nontrivial.
- function Is_Null_Record_Type (T : Entity_Id) return Boolean;
- -- Determine whether T is declared with a null record definition or a
- -- null component list.
+ function Is_Null_Extension
+ (T : Entity_Id; Ignore_Privacy : Boolean := False) return Boolean;
+ -- Given a tagged type, returns True if argument is a type extension
+ -- that introduces no new components (discriminant or nondiscriminant).
+ -- Ignore_Privacy should be True for use in implementing dynamic semantics.
+
+ function Is_Null_Extension_Of
+ (Descendant, Ancestor : Entity_Id) return Boolean;
+ -- Given two tagged types, the first a descendant of the second,
+ -- returns True if every component of Descendant is inherited
+ -- (directly or indirectly) from Ancestor. Privacy is ignored.
+
+ function Is_Null_Record_Definition (Record_Def : Node_Id) return Boolean;
+ -- Returns True for an N_Record_Definition node that has no user-defined
+ -- components (and no variant part).
+
+ function Is_Null_Record_Type
+ (T : Entity_Id; Ignore_Privacy : Boolean := False) return Boolean;
+ -- Determine whether T is declared with a null record definition, a
+ -- null component list, or as a type derived from a null record type
+ -- (with a null extension if tagged). Returns True for interface types,
+ -- False for discriminated types.
function Is_Object_Image (Prefix : Node_Id) return Boolean;
-- Returns True if an 'Img, 'Image, 'Wide_Image, or 'Wide_Wide_Image