[Ada] Tidy up implementation of Has_Compatible_Type
Pierre-Marie de Rodat
Tue Nov 9 09:46:26 GMT 2021
Has_Compatible_Type is essentially a wrapper around Covers in Sem_Type that
handles overloading and a few other details, i.e. calling:
Has_Compatible_Type (N, Typ)
is morally equivalent to calling:
Covers (Typ, Etype (N)) or Covers (Typ, Interp (N))
Except that the implementation also performs the reversed tests when Typ is
neither a tagged nor an anonymous access type and this is questionable.
This change removes the reversed tests in the general case and add them back
only in the few cases where they are still needed for now. This reduces the
total number of calls to Covers by 50%.
Tested on x86_64-pc-linux-gnu, committed on trunk
* sem_ch4.adb (Analyze_Membership_Op) <Find_Interpretation>: Handle
both overloaded and non-overloaded cases.
<Try_One_Interp>: Do a reversed call to Covers if the outcome of the
call to Has_Compatible_Type is false.
Simplify implementation after change to Find_Interpretation.
(Analyze_User_Defined_Binary_Op): Be prepared for previous errors.
(Find_Comparison_Types) <Try_One_Interp>: Do a reversed call to
Covers if the outcome of the call to Has_Compatible_Type is false.
(Find_Equality_Types) <Try_One_Interp>: Likewise.
* sem_type.adb (Has_Compatible_Type): Remove the reversed calls to
Covers. Add explicit return on all paths.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 7981 bytes
Desc: not available
More information about the Gcc-patches