]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Mon, 29 Aug 2011 13:31:02 +0000 (15:31 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 29 Aug 2011 13:31:02 +0000 (15:31 +0200)
2011-08-29  Emmanuel Briot  <briot@adacore.com>

* make.adb, prj.adb, prj.ads (Compute_All_Imported_Projects): Also
initialize aggregated projects.

2011-08-29  Ed Schonberg  <schonberg@adacore.com>

* sem_ch8.adb (Find_Renamed_Entity): Within an instance, use scope
depth of candidates to resolve a potentially spurious ambiguity between
two visible subprograms.

From-SVN: r178225

gcc/ada/ChangeLog
gcc/ada/make.adb
gcc/ada/prj.adb
gcc/ada/prj.ads
gcc/ada/sem_ch8.adb

index d99c28ab75ef5dc0626830d4858a4b8f1c59d20b..f96c6c882dc2225221493012c8935052ebd981a0 100644 (file)
@@ -1,3 +1,14 @@
+2011-08-29  Emmanuel Briot  <briot@adacore.com>
+
+       * make.adb, prj.adb, prj.ads (Compute_All_Imported_Projects): Also
+       initialize aggregated projects.
+
+2011-08-29  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_ch8.adb (Find_Renamed_Entity): Within an instance, use scope
+       depth of candidates to resolve a potentially spurious ambiguity between
+       two visible subprograms.
+
 2011-08-29  Yannick Moy  <moy@adacore.com>
 
        * sem_prag.adb (Analyze_Pragma): Allow Test_Case pragma without
index 7b9087f4bc3e40e2b90f6e0e9adecd13d1d5938a..3cf73c8e449d82d0bb7e8e3f0e0b8745b39329f8 100644 (file)
@@ -6621,7 +6621,7 @@ package body Make is
          Add_Object_Directories (Main_Project, Project_Tree);
 
          Recursive_Compute_Depth (Main_Project);
-         Compute_All_Imported_Projects (Project_Tree);
+         Compute_All_Imported_Projects (Main_Project, Project_Tree);
 
       else
 
index fc65860aee27668711adace057123aa6dc0d99d9..63fb12759deb0184c870764c3f69315cbe200e01 100644 (file)
@@ -1283,72 +1283,97 @@ package body Prj is
    -- Compute_All_Imported_Projects --
    -----------------------------------
 
-   procedure Compute_All_Imported_Projects (Tree : Project_Tree_Ref) is
-      Project : Project_Id;
-
-      procedure Recursive_Add
-        (Prj   : Project_Id;
-         Tree  : Project_Tree_Ref;
-         Dummy : in out Boolean);
-      --  Recursively add the projects imported by project Project, but not
-      --  those that are extended.
-
-      -------------------
-      -- Recursive_Add --
-      -------------------
-
-      procedure Recursive_Add
-        (Prj   : Project_Id;
-         Tree  : Project_Tree_Ref;
-         Dummy : in out Boolean)
+   procedure Compute_All_Imported_Projects
+     (Root_Project : Project_Id;
+      Tree         : Project_Tree_Ref)
+   is
+      procedure Analyze_Tree
+        (Local_Root : Project_Id; Local_Tree : Project_Tree_Ref);
+      --  Process Project and all its aggregated project to analyze their own
+      --  imported projects.
+
+      ------------------
+      -- Analyze_Tree --
+      ------------------
+
+      procedure Analyze_Tree
+        (Local_Root : Project_Id; Local_Tree : Project_Tree_Ref)
       is
-         pragma Unreferenced (Dummy, Tree);
-         List    : Project_List;
-         Prj2    : Project_Id;
+         pragma Unreferenced (Local_Root);
+
+         Project : Project_Id;
+
+         procedure Recursive_Add
+           (Prj   : Project_Id;
+            Tree  : Project_Tree_Ref;
+            Dummy : in out Boolean);
+         --  Recursively add the projects imported by project Project, but not
+         --  those that are extended.
+
+         -------------------
+         -- Recursive_Add --
+         -------------------
+
+         procedure Recursive_Add
+           (Prj   : Project_Id;
+            Tree  : Project_Tree_Ref;
+            Dummy : in out Boolean)
+         is
+            pragma Unreferenced (Dummy, Tree);
+            List    : Project_List;
+            Prj2    : Project_Id;
 
-      begin
-         --  A project is not importing itself
+         begin
+            --  A project is not importing itself
 
-         Prj2 := Ultimate_Extending_Project_Of (Prj);
+            Prj2 := Ultimate_Extending_Project_Of (Prj);
 
-         if Project /= Prj2 then
+            if Project /= Prj2 then
 
-            --  Check that the project is not already in the list. We know the
-            --  one passed to Recursive_Add have never been visited before, but
-            --  the one passed it are the extended projects.
+               --  Check that the project is not already in the list. We know
+               --  the one passed to Recursive_Add have never been visited
+               --  before, but the one passed it are the extended projects.
 
-            List := Project.All_Imported_Projects;
-            while List /= null loop
-               if List.Project = Prj2 then
-                  return;
-               end if;
+               List := Project.All_Imported_Projects;
+               while List /= null loop
+                  if List.Project = Prj2 then
+                     return;
+                  end if;
 
-               List := List.Next;
-            end loop;
+                  List := List.Next;
+               end loop;
 
-            --  Add it to the list
+               --  Add it to the list
 
-            Project.All_Imported_Projects :=
-              new Project_List_Element'
-                (Project => Prj2,
-                 Next    => Project.All_Imported_Projects);
-         end if;
-      end Recursive_Add;
+               Project.All_Imported_Projects :=
+                 new Project_List_Element'
+                   (Project => Prj2,
+                    Next    => Project.All_Imported_Projects);
+            end if;
+         end Recursive_Add;
 
-      procedure For_All_Projects is
-        new For_Every_Project_Imported (Boolean, Recursive_Add);
+         procedure For_All_Projects is
+           new For_Every_Project_Imported (Boolean, Recursive_Add);
 
-      Dummy : Boolean := False;
-      List  : Project_List;
+         Dummy   : Boolean := False;
+         List    : Project_List;
+      begin
+         List := Local_Tree.Projects;
+         while List /= null loop
+            Project := List.Project;
+            Free_List
+              (Project.All_Imported_Projects, Free_Project => False);
+            For_All_Projects
+              (Project, Local_Tree, Dummy, Include_Aggregated => False);
+            List := List.Next;
+         end loop;
+      end Analyze_Tree;
+
+      procedure For_Aggregates is
+        new For_Project_And_Aggregated (Analyze_Tree);
 
    begin
-      List := Tree.Projects;
-      while List /= null loop
-         Project := List.Project;
-         Free_List (Project.All_Imported_Projects, Free_Project => False);
-         For_All_Projects (Project, Tree, Dummy, Include_Aggregated => False);
-         List := List.Next;
-      end loop;
+      For_Aggregates (Root_Project, Tree);
    end Compute_All_Imported_Projects;
 
    -------------------
index aa953b359318a9c7c7fe4ced981dab6dfac27277..6cd46d323ac275d97c5bca9d8632498ff25d0306 100644 (file)
@@ -909,9 +909,11 @@ package Prj is
    --  If Only_If_Ada is True, then No_Name will be returned when the project
    --  doesn't Ada sources.
 
-   procedure Compute_All_Imported_Projects (Tree : Project_Tree_Ref);
+   procedure Compute_All_Imported_Projects
+     (Root_Project : Project_Id;
+      Tree         : Project_Tree_Ref);
    --  For all projects in the tree, compute the list of the projects imported
-   --  directly or indirectly by project Project. The result is stored in
+   --  directly or indirectly by project Root_Project. The result is stored in
    --  Project.All_Imported_Projects for each project
 
    function Ultimate_Extending_Project_Of
index 6340b2a0229d5a474dcca97aa6ec4f6a2ed62655..deb25af66060c5ced92bf20661307d6b6d72bd4d 100644 (file)
@@ -4841,7 +4841,9 @@ package body Sem_Ch8 is
             Set_Entity_Or_Discriminal (N, E);
 
             if Ada_Version >= Ada_2012
-              and then Nkind (Parent (N)) in N_Subexpr
+              and then
+                (Nkind (Parent (N)) in N_Subexpr
+                  or else Nkind (Parent (N)) = N_Object_Declaration)
             then
                Check_Implicit_Dereference (N, Etype (E));
             end if;
@@ -5531,13 +5533,30 @@ package body Sem_Ch8 is
 
                      if Present (Inst) then
                         if Within (It.Nam, Inst) then
-                           return (It.Nam);
+                           if Within (Old_S, Inst) then
+
+                              --  Choose the innermost subprogram, which would
+                              --  have hidden the outer one in the generic.
+
+                              if Scope_Depth (It.Nam) <
+                                Scope_Depth (Old_S)
+                              then
+                                 return Old_S;
+
+                              else
+                                 return It.Nam;
+                              end if;
+                           end if;
+
                         elsif Within (Old_S, Inst) then
                            return (Old_S);
+
                         else
                            return Report_Overload;
                         end if;
 
+                     --  If not within an instance, ambiguity is real.
+
                      else
                         return Report_Overload;
                      end if;