+2017-01-23 Bob Duff <duff@adacore.com>
+
+ * sem_res.adb (Resolve_Call): In the part of the code where
+ it is deciding whether to turn the call into an indexed
+ component, avoid doing so if the call is to an instance of
+ Unchecked_Conversion. Otherwise, the compiler turns it into an
+ indexed component, and resolution of that turns it back into a
+ function call, and so on, resulting in infinite recursion.
+ * sem_util.adb (Needs_One_Actual): If the first formal has a
+ default, then return False.
+
2017-01-21 Eric Botcazou <ebotcazou@adacore.com>
* sem_eval.adb (Compile_Time_Compare): Reinstate the expr+literal (etc)
-- component type of that array type, the node is really an indexing of
-- the parameterless call. Resolve as such. A pathological case occurs
-- when the type of the component is an access to the array type. In
- -- this case the call is truly ambiguous.
+ -- this case the call is truly ambiguous. If the call is to an intrinsic
+ -- subprogram, it can't be an indexed component. This check is necessary
+ -- because if it's Unchecked_Conversion, and we have "type T_Ptr is
+ -- access T;" and "type T is array (...) of T_Ptr;" (i.e. an array of
+ -- pointers to the same array), the compiler gets confused and does an
+ -- infinite recursion.
elsif (Needs_No_Actuals (Nam) or else Needs_One_Actual (Nam))
and then
(Is_Access_Type (Etype (Nam))
and then Is_Array_Type (Designated_Type (Etype (Nam)))
and then
- Covers (Typ, Component_Type (Designated_Type (Etype (Nam))))))
+ Covers (Typ, Component_Type (Designated_Type (Etype (Nam))))
+ and then not Is_Intrinsic_Subprogram (Entity (Subp))))
then
declare
Index_Node : Node_Id;
begin
-- Ada 2005 or later, and formals present
- if Ada_Version >= Ada_2005 and then Present (First_Formal (E)) then
+ if Ada_Version >= Ada_2005
+ and then Present (First_Formal (E))
+ and then No (Default_Value (First_Formal (E)))
+ then
Formal := Next_Formal (First_Formal (E));
while Present (Formal) loop
if No (Default_Value (Formal)) then