Commit 53b10ce9 by Arnaud Charlet

[multiple changes]

2009-07-29  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch6.adb (Check_Overriding_Indicator): Handle properly overriding
	indicators on user-defined operators.

2009-07-29  Vadim Godunko  <godunko@adacore.com>

	* g-socket.adb (Receive_Vector): Add comment.

From-SVN: r150200
parent d06b3b1d
2009-07-29 Ed Schonberg <schonberg@adacore.com>
* sem_ch6.adb (Check_Overriding_Indicator): Handle properly overriding
indicators on user-defined operators.
2009-07-29 Vadim Godunko <godunko@adacore.com>
* g-socket.adb (Receive_Vector): Add comment.
2009-07-29 Javier Miranda <miranda@adacore.com> 2009-07-29 Javier Miranda <miranda@adacore.com>
* frontend.adb (Frontend): Code cleanup. * frontend.adb (Frontend): Code cleanup.
......
...@@ -1666,6 +1666,9 @@ package body GNAT.Sockets is ...@@ -1666,6 +1666,9 @@ package body GNAT.Sockets is
Msg_Iov => Vector'Address, Msg_Iov => Vector'Address,
Msg_Iovlen => Msg_Iovlen =>
SOSC.Msg_Iovlen_T'Min (Vector'Length, SOSC.IOV_MAX), SOSC.Msg_Iovlen_T'Min (Vector'Length, SOSC.IOV_MAX),
-- recvmsg(2) returns EMSGSIZE on Linux (and probably on other
-- platforms) when the supplied vector is longer than IOV_MAX,
-- so use minimum of the two lengths.
Msg_Control => System.Null_Address, Msg_Control => System.Null_Address,
Msg_Controllen => 0, Msg_Controllen => 0,
Msg_Flags => 0); Msg_Flags => 0);
......
...@@ -4375,6 +4375,13 @@ package body Sem_Ch6 is ...@@ -4375,6 +4375,13 @@ package body Sem_Ch6 is
elsif Ekind (Subp) = E_Entry then elsif Ekind (Subp) = E_Entry then
Decl := Parent (Subp); Decl := Parent (Subp);
-- No point in analyzing a malformed operator
elsif Nkind (Subp) = N_Defining_Operator_Symbol
and then Error_Posted (Subp)
then
return;
else else
Decl := Unit_Declaration_Node (Subp); Decl := Unit_Declaration_Node (Subp);
end if; end if;
...@@ -4476,7 +4483,8 @@ package body Sem_Ch6 is ...@@ -4476,7 +4483,8 @@ package body Sem_Ch6 is
Style.Missing_Overriding (Decl, Subp); Style.Missing_Overriding (Decl, Subp);
end if; end if;
-- If Subp is an operator, it may override a predefined operation. -- If Subp is an operator, it may override a predefined operation, if
-- it is defined in the same scope as the type to which it applies.
-- In that case overridden_subp is empty because of our implicit -- In that case overridden_subp is empty because of our implicit
-- representation for predefined operators. We have to check whether the -- representation for predefined operators. We have to check whether the
-- signature of Subp matches that of a predefined operator. Note that -- signature of Subp matches that of a predefined operator. Note that
...@@ -4487,10 +4495,18 @@ package body Sem_Ch6 is ...@@ -4487,10 +4495,18 @@ package body Sem_Ch6 is
-- explicit overridden operation. -- explicit overridden operation.
elsif Nkind (Subp) = N_Defining_Operator_Symbol then elsif Nkind (Subp) = N_Defining_Operator_Symbol then
declare
Typ : constant Entity_Id :=
Base_Type (Etype (First_Formal (Subp)));
Can_Override : constant Boolean :=
Operator_Matches_Spec (Subp, Subp)
and then Scope (Subp) = Scope (Typ)
and then not Is_Class_Wide_Type (Typ);
begin
if Must_Not_Override (Spec) then if Must_Not_Override (Spec) then
-- If this is not a primitive operation or protected subprogram, -- If this is not a primitive or a protected subprogram,
-- then "not overriding" is illegal. -- then "not overriding" is illegal.
if not Is_Primitive if not Is_Primitive
...@@ -4500,22 +4516,23 @@ package body Sem_Ch6 is ...@@ -4500,22 +4516,23 @@ package body Sem_Ch6 is
("overriding indicator only allowed " ("overriding indicator only allowed "
& "if subprogram is primitive", Subp); & "if subprogram is primitive", Subp);
elsif Operator_Matches_Spec (Subp, Subp) then elsif Can_Override then
Error_Msg_NE Error_Msg_NE
("subprogram & overrides predefined operator ", Spec, Subp); ("subprogram & overrides predefined operator ",
Spec, Subp);
end if; end if;
elsif Must_Override (Spec) then elsif Must_Override (Spec) then
if Is_Overriding_Operation (Subp) then if Is_Overriding_Operation (Subp) then
Set_Is_Overriding_Operation (Subp); Set_Is_Overriding_Operation (Subp);
elsif not Operator_Matches_Spec (Subp, Subp) then elsif not Can_Override then
Error_Msg_NE ("subprogram & is not overriding", Spec, Subp); Error_Msg_NE ("subprogram & is not overriding", Spec, Subp);
end if; end if;
elsif not Error_Posted (Subp) elsif not Error_Posted (Subp)
and then Style_Check and then Style_Check
and then Operator_Matches_Spec (Subp, Subp) and then Can_Override
and then and then
not Is_Predefined_File_Name not Is_Predefined_File_Name
(Unit_File_Name (Get_Source_Unit (Subp))) (Unit_File_Name (Get_Source_Unit (Subp)))
...@@ -4535,6 +4552,7 @@ package body Sem_Ch6 is ...@@ -4535,6 +4552,7 @@ package body Sem_Ch6 is
Style.Missing_Overriding (Decl, Subp); Style.Missing_Overriding (Decl, Subp);
end if; end if;
end if; end if;
end;
elsif Must_Override (Spec) then elsif Must_Override (Spec) then
if Ekind (Subp) = E_Entry then if Ekind (Subp) = E_Entry then
......
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