+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>
* gnat_rm.texi: Doc clarifications.
if Present (L) then
Context := Parent (L);
- if Nkind (Context) = N_Package_Specification
- and then L = Visible_Declarations (Context)
- then
- Analyze_Package_Contract (Defining_Entity (Context));
+ if Nkind (Context) = N_Package_Specification then
+
+ -- When a package has private declarations, its contract must be
+ -- 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
In_Package_Body := True;
with Einfo; use Einfo;
with Errout; use Errout;
with Namet; use Namet;
+with Nlists; use Nlists;
with Opt; use Opt;
with Sinfo; use Sinfo;
with Sinput; use Sinput;
------------------------
procedure Missing_Overriding (N : Node_Id; E : Entity_Id) is
+ Nod : Node_Id;
begin
-- Perform the check on source subprograms and on subprogram instances,
if Style_Check_Missing_Overriding
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
+ -- 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
Error_Msg_NE -- CODEFIX
("(style) missing OVERRIDING indicator in body of&", N, E);
else
Error_Msg_NE -- CODEFIX
("(style) missing OVERRIDING indicator in declaration of&",
- N, E);
+ Nod, E);
end if;
end if;
end Missing_Overriding;