From 476b301a0c62213400f5208c55a2a0f1120790ce Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Wed, 19 Feb 2014 12:18:32 +0100 Subject: [PATCH] [multiple changes] 2014-02-19 Hristian Kirtchev * 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 * 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 --- gcc/ada/ChangeLog | 15 +++++++++++++++ gcc/ada/sem_ch3.adb | 22 ++++++++++++++++++---- gcc/ada/style.adb | 19 +++++++++++++++++-- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d801603c624..567aa0d9d30 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,18 @@ +2014-02-19 Hristian Kirtchev + + * 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 + + * 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 * gnat_rm.texi: Doc clarifications. diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index daa4f4e51ce..98991e2bbc7 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -2342,10 +2342,24 @@ package body Sem_Ch3 is 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; diff --git a/gcc/ada/style.adb b/gcc/ada/style.adb index 33e0077e0d2..fffcf360cb4 100644 --- a/gcc/ada/style.adb +++ b/gcc/ada/style.adb @@ -29,6 +29,7 @@ with Csets; use Csets; 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; @@ -258,6 +259,7 @@ package body Style is ------------------------ procedure Missing_Overriding (N : Node_Id; E : Entity_Id) is + Nod : Node_Id; begin -- Perform the check on source subprograms and on subprogram instances, @@ -266,15 +268,28 @@ package body Style is 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; -- 2.30.2