sem_res.adb (Resolve_Call): In the part of the code where it is deciding whether to turn the call into an...

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.

From-SVN: r244774
This commit is contained in:
Bob Duff 2017-01-23 11:13:23 +00:00 committed by Arnaud Charlet
parent e3d53f96ed
commit be4e989cd1
3 changed files with 23 additions and 3 deletions

View File

@ -1,3 +1,14 @@
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)

View File

@ -5974,7 +5974,12 @@ package body Sem_Res is
-- 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
@ -5984,7 +5989,8 @@ package body Sem_Res is
(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;

View File

@ -16089,7 +16089,10 @@ package body Sem_Util is
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