diff options
author | Ed Schonberg <schonberg@adacore.com> | 2019-08-19 08:36:44 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-08-19 08:36:44 +0000 |
commit | 432c8cdddae4ad6439ac1f85b30919d5bb91d3e1 (patch) | |
tree | d07a989f09cbe87aeaeefc3072e2c44ea4b64ecd /gcc | |
parent | bd5ed03ae9217ae903131e7345cf4ef7e6ba3437 (diff) | |
download | gcc-432c8cdddae4ad6439ac1f85b30919d5bb91d3e1.zip gcc-432c8cdddae4ad6439ac1f85b30919d5bb91d3e1.tar.gz gcc-432c8cdddae4ad6439ac1f85b30919d5bb91d3e1.tar.bz2 |
[Ada] Legality of protected subp. implementing interface operations
This patch refines the predicate that implements rule in RM 9.4 (11.9/2)
Compiling b94.ads must yield:
b94.ads:11:17: illegal overriding of subprogram inherited from interface
b94.ads:11:17: first formal of "N" declared at line 8 must be of mode
"out", "in out" or access-to-variable
----
package B94 is
type Prot2_Int is protected interface;
procedure J (PI : in Prot2_Int; N : in Integer) is null;
procedure K (PI : in out Prot2_Int; N : in Integer) is null;
procedure L (PI : out Prot2_Int; N : in Integer) is null;
procedure M (PI : access Prot2_Int; N : in Integer) is null;
procedure N (PI : access constant Prot2_Int; N : in Integer) is null;
protected type Protected_2 is new Prot2_Int with
procedure N (N : in Integer); -- ERROR: {7;1}
end Protected_2;
end B94;
2019-08-19 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch6.adb (Check_Synchronized_Overriding): Complete
predicate that applies legality check in 9.4 (11.9/2): if an
inherited subprogram is implemented by a protected procedure or
entry, its first paarameter must be out, in_out or
access_to_varible.
From-SVN: r274655
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/ada/sem_ch6.adb | 23 |
2 files changed, 27 insertions, 4 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index f193063..313a5ef 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,11 @@ +2019-08-19 Ed Schonberg <schonberg@adacore.com> + + * sem_ch6.adb (Check_Synchronized_Overriding): Complete + predicate that applies legality check in 9.4 (11.9/2): if an + inherited subprogram is implemented by a protected procedure or + entry, its first paarameter must be out, in_out or + access_to_varible. + 2019-08-19 Javier Miranda <miranda@adacore.com> PR ada/65696 diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index e176535..fb50ec7 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -7034,6 +7034,11 @@ package body Sem_Ch6 is In_Scope : Boolean; Typ : Entity_Id; + function Is_Valid_Formal (F : Entity_Id) return Boolean; + -- Predicate for legality rule in 9.4 (11.9/2): If an inherited + -- subprogram is implemented by a protected procedure or entry, + -- its first parameter must be out, in out, or access-to-variable. + function Matches_Prefixed_View_Profile (Prim_Params : List_Id; Iface_Params : List_Id) return Boolean; @@ -7042,6 +7047,19 @@ package body Sem_Ch6 is -- Iface_Params. Also determine if the type of first parameter of -- Iface_Params is an implemented interface. + ---------------------- + -- Is_Valid_Formal -- + ---------------------- + + function Is_Valid_Formal (F : Entity_Id) return Boolean is + begin + return + Ekind_In (F, E_In_Out_Parameter, E_Out_Parameter) + or else + (Nkind (Parameter_Type (Parent (F))) = N_Access_Definition + and then not Constant_Present (Parameter_Type (Parent (F)))); + end Is_Valid_Formal; + ----------------------------------- -- Matches_Prefixed_View_Profile -- ----------------------------------- @@ -7295,10 +7313,7 @@ package body Sem_Ch6 is if Ekind_In (Candidate, E_Entry, E_Procedure) and then Is_Protected_Type (Typ) - and then Ekind (Formal) /= E_In_Out_Parameter - and then Ekind (Formal) /= E_Out_Parameter - and then Nkind (Parameter_Type (Parent (Formal))) /= - N_Access_Definition + and then not Is_Valid_Formal (Formal) then null; |