+2018-12-11 Piotr Trojanek <trojanek@adacore.com>
+
+ * sem_util.adb (Is_Subprogram_Stub_Without_Prior_Declaration):
+ Return False on stubs that complete a generic subprogram.
+ * sem_util.ads: Update corresponding comment.
+
2018-12-11 Ed Schonberg <schonberg@adacore.com>
* sem_ch4.adb (Analyze_Allocator): In GNATprove mode build a
(N : Node_Id) return Boolean
is
begin
- -- A subprogram stub without prior declaration serves as declaration for
- -- the actual subprogram body. As such, it has an attached defining
- -- entity of E_[Generic_]Function or E_[Generic_]Procedure.
+ pragma Assert (Nkind (N) = N_Subprogram_Body_Stub);
- return Nkind (N) = N_Subprogram_Body_Stub
- and then Ekind (Defining_Entity (N)) /= E_Subprogram_Body;
+ case Ekind (Defining_Entity (N)) is
+
+ -- A subprogram stub without prior declaration serves as declaration
+ -- for the actual subprogram body. As such, it has an attached
+ -- defining entity of E_Function or E_Procedure.
+
+ when E_Function
+ | E_Procedure
+ =>
+ return True;
+
+ -- Otherwise, it is completes a [generic] subprogram declaration
+
+ when E_Generic_Function
+ | E_Generic_Procedure
+ | E_Subprogram_Body
+ =>
+ return False;
+
+ when others =>
+ raise Program_Error;
+ end case;
end Is_Subprogram_Stub_Without_Prior_Declaration;
---------------------------
function Is_Subprogram_Stub_Without_Prior_Declaration
(N : Node_Id) return Boolean;
- -- Return True if N is a subprogram stub with no prior subprogram
- -- declaration.
+ -- Given an N_Subprogram_Body_Stub node N, return True if N is a subprogram
+ -- stub with no prior subprogram declaration.
function Is_Suitable_Primitive (Subp_Id : Entity_Id) return Boolean;
-- Determine whether arbitrary subprogram Subp_Id may act as a primitive of