Commit cc821e65 by Claire Dross Committed by Pierre-Marie de Rodat

[Ada] Allow for GNATprove specific versions of routines from Sem_Disp

2018-05-28  Claire Dross  <dross@adacore.com>

gcc/ada/

	* sem_disp.ads, sem_disp.adb (Inheritance_Utilities): Package for
	generic inheritance utilities.
	(Generic_Inherited_Subprograms): Generic version of
	Inherited_Subprograms, generic in Find_Dispatching_Type function.
	(Generic_Is_Overriding_Subprogram): Generic version of
	Is_Overriding_Subprogram, generic in Find_Dispatching_Type function.
	(Inherited_Subprograms): Instance of Generic_Inherited_Subprograms with
	Sem_Disp.Find_Dispatching_Type.
	(Is_Overriding_Subprogram): Instance of
	Generic_Is_Overriding_Subprogram with Sem_Disp.Find_Dispatching_Type.
	(Inheritance_Utilities_Inst): Instance of Inheritance_Utilities
	with Sem_Disp.Find_Dispatching_Type.

From-SVN: r260835
parent 0c386027
2018-05-28 Claire Dross <dross@adacore.com>
* sem_disp.ads, sem_disp.adb (Inheritance_Utilities): Package for
generic inheritance utilities.
(Generic_Inherited_Subprograms): Generic version of
Inherited_Subprograms, generic in Find_Dispatching_Type function.
(Generic_Is_Overriding_Subprogram): Generic version of
Is_Overriding_Subprogram, generic in Find_Dispatching_Type function.
(Inherited_Subprograms): Instance of Generic_Inherited_Subprograms with
Sem_Disp.Find_Dispatching_Type.
(Is_Overriding_Subprogram): Instance of
Generic_Is_Overriding_Subprogram with Sem_Disp.Find_Dispatching_Type.
(Inheritance_Utilities_Inst): Instance of Inheritance_Utilities
with Sem_Disp.Find_Dispatching_Type.
2018-05-28 Eric Botcazou <ebotcazou@adacore.com> 2018-05-28 Eric Botcazou <ebotcazou@adacore.com>
* exp_ch4.adb (Expand_Composite_Equality): For a composite (or FP) * exp_ch4.adb (Expand_Composite_Equality): For a composite (or FP)
......
...@@ -2201,6 +2201,12 @@ package body Sem_Disp is ...@@ -2201,6 +2201,12 @@ package body Sem_Disp is
end Find_Primitive_Covering_Interface; end Find_Primitive_Covering_Interface;
--------------------------- ---------------------------
-- Inheritance_Utilities --
---------------------------
package body Inheritance_Utilities is
---------------------------
-- Inherited_Subprograms -- -- Inherited_Subprograms --
--------------------------- ---------------------------
...@@ -2245,7 +2251,13 @@ package body Sem_Disp is ...@@ -2245,7 +2251,13 @@ package body Sem_Disp is
begin begin
pragma Assert (not (No_Interfaces and Interfaces_Only)); pragma Assert (not (No_Interfaces and Interfaces_Only));
if Present (S) and then Is_Dispatching_Operation (S) then -- When used from backends, visibility can be handled differently
-- resulting in no dispatching type being found.
if Present (S)
and then Is_Dispatching_Operation (S)
and then Present (Find_DT (S))
then
-- Deal with direct inheritance -- Deal with direct inheritance
...@@ -2257,7 +2269,7 @@ package body Sem_Disp is ...@@ -2257,7 +2269,7 @@ package body Sem_Disp is
or else or else
(No_Interfaces (No_Interfaces
and then and then
Is_Interface (Find_Dispatching_Type (Parent_Op))); Is_Interface (Find_DT (Parent_Op)));
if Is_Subprogram_Or_Generic_Subprogram (Parent_Op) then if Is_Subprogram_Or_Generic_Subprogram (Parent_Op) then
Store_IS (Parent_Op); Store_IS (Parent_Op);
...@@ -2278,7 +2290,7 @@ package body Sem_Disp is ...@@ -2278,7 +2290,7 @@ package body Sem_Disp is
Elmt : Elmt_Id; Elmt : Elmt_Id;
begin begin
Tag_Typ := Find_Dispatching_Type (S); Tag_Typ := Find_DT (S);
-- In the presence of limited views there may be no visible -- In the presence of limited views there may be no visible
-- dispatching type. Primitives will be inherited when non- -- dispatching type. Primitives will be inherited when non-
...@@ -2301,13 +2313,15 @@ package body Sem_Disp is ...@@ -2301,13 +2313,15 @@ package body Sem_Disp is
while Present (Elmt) loop while Present (Elmt) loop
Prim := Node (Elmt); Prim := Node (Elmt);
-- The following test eliminates some odd cases in which -- The following test eliminates some odd cases in
-- Ekind (Prim) is Void, to be investigated further ??? -- which Ekind (Prim) is Void, to be investigated
-- further ???
if not Is_Subprogram_Or_Generic_Subprogram (Prim) then if not Is_Subprogram_Or_Generic_Subprogram (Prim) then
null; null;
-- For [generic] subprogram, look at interface alias -- For [generic] subprogram, look at interface
-- alias.
elsif Present (Interface_Alias (Prim)) elsif Present (Interface_Alias (Prim))
and then Alias (Prim) = S and then Alias (Prim) = S
...@@ -2333,6 +2347,36 @@ package body Sem_Disp is ...@@ -2333,6 +2347,36 @@ package body Sem_Disp is
return Result (1 .. N); return Result (1 .. N);
end Inherited_Subprograms; end Inherited_Subprograms;
------------------------------
-- Is_Overriding_Subprogram --
------------------------------
function Is_Overriding_Subprogram (E : Entity_Id) return Boolean is
Inherited : constant Subprogram_List :=
Inherited_Subprograms (E, One_Only => True);
begin
return Inherited'Length > 0;
end Is_Overriding_Subprogram;
end Inheritance_Utilities;
--------------------------------
-- Inheritance_Utilities_Inst --
--------------------------------
package Inheritance_Utilities_Inst is new
Inheritance_Utilities (Find_Dispatching_Type);
---------------------------
-- Inherited_Subprograms --
---------------------------
function Inherited_Subprograms
(S : Entity_Id;
No_Interfaces : Boolean := False;
Interfaces_Only : Boolean := False;
One_Only : Boolean := False) return Subprogram_List renames
Inheritance_Utilities_Inst.Inherited_Subprograms;
--------------------------- ---------------------------
-- Is_Dynamically_Tagged -- -- Is_Dynamically_Tagged --
--------------------------- ---------------------------
...@@ -2410,12 +2454,8 @@ package body Sem_Disp is ...@@ -2410,12 +2454,8 @@ package body Sem_Disp is
-- Is_Overriding_Subprogram -- -- Is_Overriding_Subprogram --
------------------------------ ------------------------------
function Is_Overriding_Subprogram (E : Entity_Id) return Boolean is function Is_Overriding_Subprogram (E : Entity_Id) return Boolean renames
Inherited : constant Subprogram_List := Inheritance_Utilities_Inst.Is_Overriding_Subprogram;
Inherited_Subprograms (E, One_Only => True);
begin
return Inherited'Length > 0;
end Is_Overriding_Subprogram;
-------------------------- --------------------------
-- Is_Tag_Indeterminate -- -- Is_Tag_Indeterminate --
......
...@@ -100,6 +100,24 @@ package Sem_Disp is ...@@ -100,6 +100,24 @@ package Sem_Disp is
type Subprogram_List is array (Nat range <>) of Entity_Id; type Subprogram_List is array (Nat range <>) of Entity_Id;
-- Type returned by Inherited_Subprograms function -- Type returned by Inherited_Subprograms function
generic
with function Find_DT (Subp : Entity_Id) return Entity_Id;
package Inheritance_Utilities is
-- This package provides generic versions of inheritance utilities
-- provided here. These versions are used in GNATprove backend to
-- adapt these utilities to GNATprove specific version of visibility of
-- types.
function Inherited_Subprograms
(S : Entity_Id;
No_Interfaces : Boolean := False;
Interfaces_Only : Boolean := False;
One_Only : Boolean := False) return Subprogram_List;
function Is_Overriding_Subprogram (E : Entity_Id) return Boolean;
end Inheritance_Utilities;
function Inherited_Subprograms function Inherited_Subprograms
(S : Entity_Id; (S : Entity_Id;
No_Interfaces : Boolean := False; No_Interfaces : Boolean := False;
......
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