Commit f3e0577c by Piotr Trojanek Committed by Pierre-Marie de Rodat

[Ada] Stubs that complete generic subprogram do have a "prior declaration"

The intuition behind the Is_Subprogram_Stub_Without_Prior_Declaration
utility routine is to detect stubs that act as subprogram declarations
and False on stubs that act as completions. This behaviour is now fixed
for stubs that correspond to generic subprogram declarations.

This patch affects a routine that is only used in GNATprove, so no
frontend test provided. An example where the result changed from True to
False is:

-----------
-- p.ads --
-----------

package P is
   generic
   procedure Proc;
end P;

-----------
-- p.adb --
-----------

package body P is
   procedure Proc is separate; -- now we return False for this stub
end P;

----------------
-- p-proc.adb --
----------------

separate (P)
procedure Proc is
begin
   null;
end;

2018-12-11  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

	* sem_util.adb (Is_Subprogram_Stub_Without_Prior_Declaration):
	Return False on stubs that complete a generic subprogram.
	* sem_util.ads: Update corresponding comment.

From-SVN: r266992
parent 60c14ec7
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> 2018-12-11 Ed Schonberg <schonberg@adacore.com>
* sem_ch4.adb (Analyze_Allocator): In GNATprove mode build a * sem_ch4.adb (Analyze_Allocator): In GNATprove mode build a
......
...@@ -17471,12 +17471,30 @@ package body Sem_Util is ...@@ -17471,12 +17471,30 @@ package body Sem_Util is
(N : Node_Id) return Boolean (N : Node_Id) return Boolean
is is
begin begin
-- A subprogram stub without prior declaration serves as declaration for pragma Assert (Nkind (N) = N_Subprogram_Body_Stub);
-- the actual subprogram body. As such, it has an attached defining
-- entity of E_[Generic_]Function or E_[Generic_]Procedure.
return Nkind (N) = N_Subprogram_Body_Stub case Ekind (Defining_Entity (N)) is
and then Ekind (Defining_Entity (N)) /= E_Subprogram_Body;
-- 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; end Is_Subprogram_Stub_Without_Prior_Declaration;
--------------------------- ---------------------------
......
...@@ -2001,8 +2001,8 @@ package Sem_Util is ...@@ -2001,8 +2001,8 @@ package Sem_Util is
function Is_Subprogram_Stub_Without_Prior_Declaration function Is_Subprogram_Stub_Without_Prior_Declaration
(N : Node_Id) return Boolean; (N : Node_Id) return Boolean;
-- Return True if N is a subprogram stub with no prior subprogram -- Given an N_Subprogram_Body_Stub node N, return True if N is a subprogram
-- declaration. -- stub with no prior subprogram declaration.
function Is_Suitable_Primitive (Subp_Id : Entity_Id) return Boolean; function Is_Suitable_Primitive (Subp_Id : Entity_Id) return Boolean;
-- Determine whether arbitrary subprogram Subp_Id may act as a primitive of -- Determine whether arbitrary subprogram Subp_Id may act as a primitive of
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment