summaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2017-01-23 11:13:23 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2017-01-23 11:13:23 +0000
commite3319ab10ae6caa625d81b58a0030db9b75c6d38 (patch)
tree8784926c11173491046562803de287383babcc32 /gcc/ada
parentaa521244273dd743243a2764298f964de51130a4 (diff)
downloadgcc-e3319ab10ae6caa625d81b58a0030db9b75c6d38.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@244774 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog11
-rw-r--r--gcc/ada/sem_res.adb10
-rw-r--r--gcc/ada/sem_util.adb5
3 files changed, 23 insertions, 3 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 71927a618bd..e482e850f7e 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -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)
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 1b91211ea04..58ee4036948 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 73c8ce09948..f8ac8ce0d38 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