From: Bob Duff Date: Mon, 23 Jan 2017 11:13:23 +0000 (+0000) Subject: sem_res.adb (Resolve_Call): In the part of the code where it is deciding whether... X-Git-Tag: upstream/12.2.0~41646 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=be4e989cd110e3eda9b9b14e6d3f73c9408e8816;p=platform%2Fupstream%2Fgcc.git 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 * 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 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 71927a6..e482e85 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,14 @@ +2017-01-23 Bob Duff + + * 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 * sem_eval.adb (Compile_Time_Compare): Reinstate the expr+literal (etc) diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 1b91211..58ee403 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -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; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 73c8ce0..f8ac8ce 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -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