[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Wed, 19 Feb 2014 11:18:32 +0000 (12:18 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 19 Feb 2014 11:18:32 +0000 (12:18 +0100)
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

gcc/ada/ChangeLog
gcc/ada/sem_ch3.adb
gcc/ada/style.adb

index d801603..567aa0d 100644 (file)
@@ -1,3 +1,18 @@
+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.
index daa4f4e..98991e2 100644 (file)
@@ -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;
index 33e0077..fffcf36 100644 (file)
@@ -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;