===================================================================
@@ -1256,6 +1256,11 @@
end loop;
end if;
+ -- Check whether an indirect call without actuals may be possible. This
+ -- is used when resolving calls whose result is then indexed.
+
+ May_Need_Actuals (Desig_Type);
+
-- If the return type is incomplete, this is legal as long as the type
-- is declared in the current scope and will be completed in it (rather
-- than being part of limited view).
===================================================================
@@ -5460,8 +5460,14 @@
("cannot disambiguate function call and indexing", N);
else
New_Subp := Relocate_Node (Subp);
- Set_Entity (Subp, Nam);
+ -- The called entity may be an explicit dereference, in which
+ -- case there is no entity to set.
+
+ if Nkind (New_Subp) /= N_Explicit_Dereference then
+ Set_Entity (Subp, Nam);
+ end if;
+
if (Is_Array_Type (Ret_Type)
and then Component_Type (Ret_Type) /= Any_Type)
or else
===================================================================
@@ -1037,6 +1037,9 @@
-- function that returns a pointer_to_procedure which is the entity
-- being called. Finally, F (X) may be a call to a parameterless
-- function that returns a pointer to a function with parameters.
+ -- Note that if F return an access to subprogram whose designated
+ -- type is an array, F (X) cannot be interpreted as an indirect call
+ -- through the result of the call to F.
elsif Is_Access_Type (Etype (Nam))
and then Ekind (Designated_Type (Etype (Nam))) = E_Subprogram_Type
@@ -1047,6 +1050,8 @@
(Nkind (Parent (N)) /= N_Explicit_Dereference
and then Is_Entity_Name (Nam)
and then No (First_Formal (Entity (Nam)))
+ and then not
+ Is_Array_Type (Etype (Designated_Type (Etype (Nam))))
and then Present (Actuals)))
then
Nam_Ent := Designated_Type (Etype (Nam));
@@ -2998,7 +3003,9 @@
return;
end if;
- -- An indexing requires at least one actual
+ -- An indexing requires at least one actual.The name of the call cannot
+ -- be an implicit indirect call, so it cannot be a generated explicit
+ -- dereference.
if not Is_Empty_List (Actuals)
and then
@@ -3007,7 +3014,11 @@
(Needs_One_Actual (Nam)
and then Present (Next_Actual (First (Actuals)))))
then
- if Is_Array_Type (Subp_Type) then
+ if Is_Array_Type (Subp_Type)
+ and then
+ (Nkind (Name (N)) /= N_Explicit_Dereference
+ or else Comes_From_Source (Name (N)))
+ then
Is_Indexed := Try_Indexed_Call (N, Nam, Subp_Type, Must_Skip);
elsif Is_Access_Type (Subp_Type)
@@ -3046,9 +3057,14 @@
if not Norm_OK then
-- If an indirect call is a possible interpretation, indicate
- -- success to the caller.
+ -- success to the caller. This may be an indecing of an explicit
+ -- dereference of a call that returns an access type (see above).
- if Is_Indirect then
+ if Is_Indirect
+ or else (Is_Indexed
+ and then Nkind (Name (N)) = N_Explicit_Dereference
+ and then Comes_From_Source (Name (N)))
+ then
Success := True;
return;
===================================================================
@@ -211,10 +211,6 @@
-- Create the declaration for an inequality operator that is implicitly
-- created by a user-defined equality operator that yields a boolean.
- procedure May_Need_Actuals (Fun : Entity_Id);
- -- Flag functions that can be called without parameters, i.e. those that
- -- have no parameters, or those for which defaults exist for all parameters
-
procedure Process_PPCs
(N : Node_Id;
Spec_Id : Entity_Id;
===================================================================
@@ -234,6 +234,13 @@
-- E is the entity for a subprogram or generic subprogram spec. This call
-- lists all inherited Pre/Post aspects if List_Inherited_Pre_Post is True.
+ procedure May_Need_Actuals (Fun : Entity_Id);
+ -- Flag functions that can be called without parameters, i.e. those that
+ -- have no parameters, or those for which defaults exist for all parameters
+ -- Used for subprogram declarations and for access subprogram declarations,
+ -- where they apply to the anonymous designated type. On return the flag
+ -- Set_Needs_No_Actuals is set appropriately in Fun.
+
function Mode_Conformant (New_Id, Old_Id : Entity_Id) return Boolean;
-- Determine whether two callable entities (subprograms, entries,
-- literals) are mode conformant (RM 6.3.1(15))