aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/einfo.ads
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2022-01-03 11:32:48 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-09 09:27:31 +0000
commiteb05097d5508618a70b279df6d10d409eb4c60ae (patch)
tree34160b8f8a46ec7552f1c8e12d52cbdd75373887 /gcc/ada/einfo.ads
parent320eb42df09f3cb96fea9a7b090ae61d9edb20b6 (diff)
downloadgcc-eb05097d5508618a70b279df6d10d409eb4c60ae.zip
gcc-eb05097d5508618a70b279df6d10d409eb4c60ae.tar.gz
gcc-eb05097d5508618a70b279df6d10d409eb4c60ae.tar.bz2
[Ada] Revamp type resolution for comparison and equality operators
The main goal was to make it symmetrical, but this also moves error handling entirely to the second phase of type resolution. gcc/ada/ * einfo.ads (Access Kinds): Reorder and beef up. * sem.adb (Analyze): Call Analyze_Comparison_Equality_Op for all comparison and equality operators. * sem_ch4.ads (Analyze_Comparison_Op): Delete. (Analyze_Equality_Op): Likewise. (Analyze_Comparison_Equality_Op): Declare. (Ambiguous_Operands): Likewise. * sem_ch4.adb (Ambiguous_Operands): Remove declaration. (Defined_In_Scope): Delete. (Find_Comparison_Types): Merge into... (Find_Equality_Types): Merge into... (Find_Comparison_Equality_Types): ...this. Make fully symmetrical. (Analyze_Arithmetic_Op): Minor consistency tweaks. (Analyze_Comparison_Op): Merge into... (Analyze_Equality_Op): Merge into... (Analyze_Comparison_Equality_Op): ...this. Make fully symmetrical. (Analyze_Logical_Op): Minor consistency tweaks. (Analyze_Membership_Op): Make fully symmetrical. (Analyze_One_Call): Minor comment tweak. (Analyze_Operator_Call): Call Find_Comparison_Equality_Types. (Analyze_User_Defined_Binary_Op): Make fully symmetrical. (Check_Arithmetic_Pair.Specific_Type): Delete. (Diagnose_Call): Add special handling for "+" operator. (Operator_Check): Call Analyze_Comparison_Equality_Op. * sem_ch8.adb (Has_Implicit_Operator): Add Is_Type guard for boolean operators, use Valid_Comparison_Arg and Valid_Equality_Arg for resp. comparison and equality operators. * sem_res.adb (Check_For_Visible_Operator): Call Is_Visible_Operator (Make_Call_Into_Operator): Use Preserve_Comes_From_Source. (Resolve_Actuals): Deal specifically with Any_Type actuals for user- defined comparison and equality operators. (Resolve_Call): Minor tweaks. (Resolve_Comparison_Op): Tidy up and give error for ambiguity. (Resolve_Equality_Op): Likewise, as well as other errors. (Rewrite_Renamed_Operator): Simplify. * sem_type.ads (Is_Invisible_Operator): Delete. (Is_Visible_Operator): Declare. (Has_Compatible_Type): Remove For_Comparison parameter. (Specific_Type): Declare. (Valid_Equality_Arg): Likewise. * sem_type.adb (Specific_Type): Remove declaration. (Add_One_Interp): Call Is_Visible_Operator for the visibility test. (Remove_Conversions): Rename into... (Remove_Conversions_And_Abstract_Operations): ...this. Do not apply numeric-type treatment to Any_Type. Expand the special handling for abstract interpretations to second operand. Remove obsolete code. (Disambiguate): Adjust to above renaming. Tweak to hidden case and call Remove_Conversions_And_Abstract_Operations for operators too. (Entity_Matches_Spec): Minor tweak. (Find_Unique_Type): Simplify and deal with user-defined literals. (Has_Compatible_Type): Remove For_Comparison parameter and adjust. Call the Is_User_Defined_Literal predicate and remove call to the Is_Invisible_Operator predicate. (Is_Invisible_Operator): Delete. (Is_Visible_Operator): New function. (Operator_Matches_Spec): Use Valid_Equality_Arg predicate. (Specific_Type): Tidy up, make fully symmetrical and deal with private views the same way as Covers. (Valid_Comparison_Arg): Return true for Any_Composite/Any_String. (Valid_Equality_Arg): New function. * sem_util.ads (Is_User_Defined_Literal): Declare. * sem_util.adb (Is_User_Defined_Literal): New function.
Diffstat (limited to 'gcc/ada/einfo.ads')
-rw-r--r--gcc/ada/einfo.ads18
1 files changed, 12 insertions, 6 deletions
diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads
index c709a1f..9fed73d 100644
--- a/gcc/ada/einfo.ads
+++ b/gcc/ada/einfo.ads
@@ -4846,23 +4846,29 @@ package Einfo is
-- E_Access_Type,
-- E_General_Access_Type,
+-- E_Anonymous_Access_Type
+
-- E_Access_Subprogram_Type,
-- E_Anonymous_Access_Subprogram_Type,
+
-- E_Access_Protected_Subprogram_Type,
-- E_Anonymous_Access_Protected_Subprogram_Type
--- E_Anonymous_Access_Type.
--- E_Access_Subtype is for an access subtype created by a subtype
--- declaration.
+-- E_Access_Subtype is for an access subtype created by a subtype declaration
-- In addition, we define the kind E_Allocator_Type to label allocators.
-- This is because special resolution rules apply to this construct.
-- Eventually the constructs are labeled with the access type imposed by
-- the context. The backend should never see types with this Ekind.
--- Similarly, the type E_Access_Attribute_Type is used as the initial kind
--- associated with an access attribute. After resolution a specific access
--- type will be established as determined by the context.
+-- Similarly, we define the kind E_Access_Attribute_Type as the initial
+-- kind associated with an access attribute whose prefix is an object.
+-- After resolution, a specific access type will be established instead
+-- as determined by the context. Note that, for the case of an access
+-- attribute whose prefix is a subprogram, we build a corresponding type
+-- with E_Access_Subprogram_Type or E_Access_Protected_Subprogram_Type kind
+-- but whose designated type is the subprogram itself, instead of a regular
+-- E_Subprogram_Type entity.
--------------------------------------------------------
-- Description of Defined Attributes for Entity_Kinds --