Commit 476b301a by Arnaud Charlet

[multiple changes]

2014-02-19  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_ch3.adb (Analyze_Declarations): Analyze
	a package contract at the end of the private declarations (if
	applicable), otherwise analyze it and the end of the visible
	declarations.

2014-02-19  Ed Schonberg  <schonberg@adacore.com>

	* style.adb (Missing_Overriding): If subprogram is an
	instantiation, place warning on the instance node itself,
	without mention of the original generic. Do not emit message
	if explicit Ada version is older than the introduction of the
	overriding indicator.

From-SVN: r207895
parent a6ce7e76
2014-02-19 Hristian Kirtchev <kirtchev@adacore.com>
* sem_ch3.adb (Analyze_Declarations): Analyze
a package contract at the end of the private declarations (if
applicable), otherwise analyze it and the end of the visible
declarations.
2014-02-19 Ed Schonberg <schonberg@adacore.com>
* style.adb (Missing_Overriding): If subprogram is an
instantiation, place warning on the instance node itself,
without mention of the original generic. Do not emit message
if explicit Ada version is older than the introduction of the
overriding indicator.
2014-02-19 Yannick Moy <moy@adacore.com> 2014-02-19 Yannick Moy <moy@adacore.com>
* gnat_rm.texi: Doc clarifications. * gnat_rm.texi: Doc clarifications.
......
...@@ -2342,10 +2342,24 @@ package body Sem_Ch3 is ...@@ -2342,10 +2342,24 @@ package body Sem_Ch3 is
if Present (L) then if Present (L) then
Context := Parent (L); Context := Parent (L);
if Nkind (Context) = N_Package_Specification if Nkind (Context) = N_Package_Specification then
and then L = Visible_Declarations (Context)
then -- When a package has private declarations, its contract must be
Analyze_Package_Contract (Defining_Entity (Context)); -- analyzed at the end of the said declarations. This way both the
-- analysis and freeze actions are properly synchronized in case
-- of private type use within the contract.
if L = Private_Declarations (Context) then
Analyze_Package_Contract (Defining_Entity (Context));
-- Otherwise the contract is analyzed at the end of the visible
-- declarations.
elsif L = Visible_Declarations (Context)
and then No (Private_Declarations (Context))
then
Analyze_Package_Contract (Defining_Entity (Context));
end if;
elsif Nkind (Context) = N_Package_Body then elsif Nkind (Context) = N_Package_Body then
In_Package_Body := True; In_Package_Body := True;
......
...@@ -29,6 +29,7 @@ with Csets; use Csets; ...@@ -29,6 +29,7 @@ with Csets; use Csets;
with Einfo; use Einfo; with Einfo; use Einfo;
with Errout; use Errout; with Errout; use Errout;
with Namet; use Namet; with Namet; use Namet;
with Nlists; use Nlists;
with Opt; use Opt; with Opt; use Opt;
with Sinfo; use Sinfo; with Sinfo; use Sinfo;
with Sinput; use Sinput; with Sinput; use Sinput;
...@@ -258,6 +259,7 @@ package body Style is ...@@ -258,6 +259,7 @@ package body Style is
------------------------ ------------------------
procedure Missing_Overriding (N : Node_Id; E : Entity_Id) is procedure Missing_Overriding (N : Node_Id; E : Entity_Id) is
Nod : Node_Id;
begin begin
-- Perform the check on source subprograms and on subprogram instances, -- Perform the check on source subprograms and on subprogram instances,
...@@ -266,15 +268,28 @@ package body Style is ...@@ -266,15 +268,28 @@ package body Style is
if Style_Check_Missing_Overriding if Style_Check_Missing_Overriding
and then (Comes_From_Source (N) or else Is_Generic_Instance (E)) and then (Comes_From_Source (N) or else Is_Generic_Instance (E))
and then Ada_Version >= Ada_2005 and then Ada_Version_Explicit >= Ada_2005
then then
-- If the subprogram is an instantiation, its declaration appears
-- within a wrapper package that precedes the instance node. Place
-- warning on the node to avoid references to the original generic.
if Nkind (N) = N_Subprogram_Declaration
and then Is_Generic_Instance (E)
then
Nod := Next (Parent (Parent (List_Containing (N))));
else
Nod := N;
end if;
if Nkind (N) = N_Subprogram_Body then if Nkind (N) = N_Subprogram_Body then
Error_Msg_NE -- CODEFIX Error_Msg_NE -- CODEFIX
("(style) missing OVERRIDING indicator in body of&", N, E); ("(style) missing OVERRIDING indicator in body of&", N, E);
else else
Error_Msg_NE -- CODEFIX Error_Msg_NE -- CODEFIX
("(style) missing OVERRIDING indicator in declaration of&", ("(style) missing OVERRIDING indicator in declaration of&",
N, E); Nod, E);
end if; end if;
end if; end if;
end Missing_Overriding; end Missing_Overriding;
......
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