[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Mon, 9 Jul 2012 10:50:32 +0000 (12:50 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 9 Jul 2012 10:50:32 +0000 (12:50 +0200)
2012-07-09  Robert Dewar  <dewar@adacore.com>

* freeze.adb, prj-util.adb, prj-util.ads, sem_ch13.adb: Minor
reformatting.

2012-07-09  Gary Dismukes  <dismukes@adacore.com>

* sem_cat.adb (Check_Categorization_Dependencies):
Allow dependence of both Remote_Types and Remote_Call_Interface
declarations (not just Remote_Types units) on preelaborated
units, but require that the dependence be made via a private
with_clause. Issue a specialized error message.

From-SVN: r189371

gcc/ada/ChangeLog
gcc/ada/freeze.adb
gcc/ada/prj-util.adb
gcc/ada/prj-util.ads
gcc/ada/sem_cat.adb
gcc/ada/sem_ch13.adb

index d9096dcf6cc0819ade83a822338b3c780484f5b6..037566cc879787339f77a6b15ec0107557ec6888 100644 (file)
@@ -1,3 +1,16 @@
+2012-07-09  Robert Dewar  <dewar@adacore.com>
+
+       * freeze.adb, prj-util.adb, prj-util.ads, sem_ch13.adb: Minor
+       reformatting.
+
+2012-07-09  Gary Dismukes  <dismukes@adacore.com>
+
+       * sem_cat.adb (Check_Categorization_Dependencies):
+       Allow dependence of both Remote_Types and Remote_Call_Interface
+       declarations (not just Remote_Types units) on preelaborated
+       units, but require that the dependence be made via a private
+       with_clause. Issue a specialized error message.
+
 2012-07-09  Pascal Obry  <obry@adacore.com>
 
        * prj-util.adb, prj-util.ads (For_Interface_Sources): New routine.
index cee956b4839851786fc38c34dff4a53917487b02..4637e05f2fbb7e54ae276340ff712ab8f2b5dec0 100644 (file)
@@ -42,7 +42,7 @@ with Nmake;    use Nmake;
 with Opt;      use Opt;
 with Restrict; use Restrict;
 with Rident;   use Rident;
-with Rtsfind; use Rtsfind;
+with Rtsfind;  use Rtsfind;
 with Sem;      use Sem;
 with Sem_Aux;  use Sem_Aux;
 with Sem_Cat;  use Sem_Cat;
@@ -1906,6 +1906,7 @@ package body Freeze is
          Comp := First_Entity (Rec);
          Prev := Empty;
          while Present (Comp) loop
+
             --  Deal with delayed aspect specifications for components. The
             --  analysis of the aspect is required to be delayed to the freeze
             --  point, thus we analyze the pragma or attribute definition
@@ -1914,7 +1915,7 @@ package body Freeze is
             --  correspond to pragma/attribute definition clause.
 
             if Ekind (Comp) = E_Component
-               and then Has_Delayed_Aspects (Comp)
+              and then Has_Delayed_Aspects (Comp)
             then
                Push_Scope (Rec);
 
index 4ad2668f1261216feb5a3ea46139d6d911bc1fb4..1ad1aff58a72a9e4e4fc521b4c82dd0a2170c1e6 100644 (file)
@@ -398,7 +398,8 @@ package body Prj.Util is
    ---------------------------
 
    procedure For_Interface_Sources
-     (Tree : Project_Tree_Ref; Project : Project_Id)
+     (Tree    : Project_Tree_Ref;
+      Project : Project_Id)
    is
       use Ada;
       use type Ada.Containers.Count_Type;
@@ -406,7 +407,7 @@ package body Prj.Util is
       package Dep_Names is new Containers.Indefinite_Ordered_Sets (String);
 
       function Load_ALI (Filename : String) return ALI_Id;
-      --  Load an ALI file and returns its id
+      --  Load an ALI file and return its id
 
       --------------
       -- Load_ALI --
@@ -416,6 +417,7 @@ package body Prj.Util is
          Result   : ALI_Id := No_ALI_Id;
          Text     : Text_Buffer_Ptr;
          Lib_File : File_Name_Type;
+
       begin
          if Directories.Exists (Filename) then
             Name_Len := 0;
@@ -435,6 +437,8 @@ package body Prj.Util is
          return Result;
       end Load_ALI;
 
+      --  Local declarations
+
       Iter : Source_Iterator := For_Each_Source (Tree, Project);
       Sid  : Source_Id;
       ALI  : ALI_Id;
@@ -444,8 +448,10 @@ package body Prj.Util is
       Body_Needed : Boolean;
       Deps        : Dep_Names.Set;
 
+   --  Start of processing for For_Interface_Sources
+
    begin
-      --  First look at all the spec, check if the body is needed
+      --  First look at each spec, check if the body is needed
 
       loop
          Sid := Element (Iter);
@@ -457,23 +463,23 @@ package body Prj.Util is
          if Sid.Kind = Spec
            and then not Sid.Locally_Removed
            and then (Project.Standalone_Library = No
-                     or else Sid.Declared_In_Interfaces)
+                      or else Sid.Declared_In_Interfaces)
          then
             Action (Sid);
 
             --  Check ALI for dependencies on body and sep
 
-            ALI := Load_ALI
-              (Get_Name_String (Get_Object_Directory (Sid.Project, True))
-               & Get_Name_String (Sid.Dep_Name));
+            ALI :=
+              Load_ALI
+                (Get_Name_String (Get_Object_Directory (Sid.Project, True))
+                 & Get_Name_String (Sid.Dep_Name));
 
             if ALI /= No_ALI_Id then
                First_Unit := ALIs.Table (ALI).First_Unit;
                Second_Unit := No_Unit_Id;
                Body_Needed := True;
 
-               --  If there is both a spec and a body, check if they are both
-               --  needed.
+               --  If there is both a spec and a body, check if both needed
 
                if Units.Table (First_Unit).Utype = Is_Body then
                   Second_Unit := ALIs.Table (ALI).Last_Unit;
index 96bfdb8cc3b0267563698fb5a1a6e3432590f2d4..661ab2d4ccf2feb4a686370d8d02617c0ee0011a 100644 (file)
@@ -236,13 +236,14 @@ package Prj.Util is
    generic
       with procedure Action (Source : Source_Id);
    procedure For_Interface_Sources
-     (Tree : Project_Tree_Ref; Project : Project_Id);
-   --  Call Action for every sources that are needed to use Project. This
-   --  is either the sources corresponding to the unit in the Interfaces
-   --  attributes or all sources of the project. Note that only the body
-   --  needed (because the unit if generic or contains some inline pragmas)
-   --  are handled. This routine must be called only when the project as
-   --  sucessfully been built.
+     (Tree    : Project_Tree_Ref;
+      Project : Project_Id);
+   --  Call Action for every sources that are needed to use Project. This is
+   --  either the sources corresponding to the units in attribute Interfaces or
+   --  all sources of the project. Note that only the bodies that are needed
+   --  (because the unit is generic or contains some inline pragmas) are
+   --  handled. This routine must be called only when the project has been
+   --  built successfully.
 
 private
    type Text_File_Data is record
index e53645e45de3bb50106033e7b0585286946ced49..e5d4dfbadda6c428347e1b7c1705b22044f3ea56 100644 (file)
@@ -219,10 +219,14 @@ package body Sem_Cat is
          then
             null;
 
-         --  Special case: Remote_Types can depend on Preelaborated per
-         --  Ada 2005 AI 0206.
-
-         elsif Unit_Category = Remote_Types
+         --  Special case: Remote_Types and Remote_Call_Interface declarations
+         --  can depend on a preelaborated unit via a private with_clause, per
+         --  AI05-0206.
+
+         elsif (Unit_Category = Remote_Types
+                 or else Unit_Category = Remote_Call_Interface)
+           and then (Nkind (N) = N_With_Clause
+                      and then Private_Present (N))
            and then Is_Preelaborated (Depended_Entity)
          then
             null;
@@ -263,6 +267,17 @@ package body Sem_Cat is
          then
             return;
 
+         --  Dependence of Remote_Types or Remote_Call_Interface declaration
+         --  on a preelaborated unit with a normal with_clause.
+
+         elsif (Unit_Category = Remote_Types
+                 or else Unit_Category = Remote_Call_Interface)
+           and then Is_Preelaborated (Depended_Entity)
+         then
+            Error_Msg_NE
+              ("<must use private with clause for preelaborated unit& ",
+               N, Depended_Entity);
+
          --  Subunit case
 
          elsif Is_Subunit then
index 8deb37b34fc52cec7ce065e05606e4b5b9396d60..80b1ab17dae5ef0cb3b92401ca65ff2c2d542a8a 100644 (file)
@@ -6423,11 +6423,8 @@ package body Sem_Ch13 is
          --  If the end of declarations comes before any other freeze
          --  point, the Freeze_Expr is not analyzed: no check needed.
 
-         if Analyzed (Freeze_Expr)
-           and then not In_Instance
-         then
+         if Analyzed (Freeze_Expr) and then not In_Instance then
             Check_Overloaded_Name;
-
          else
             Err := False;
          end if;