]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Mon, 16 Jul 2012 10:52:21 +0000 (12:52 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 16 Jul 2012 10:52:21 +0000 (12:52 +0200)
2012-07-16  Vasiliy Fofanov  <fofanov@adacore.com>

* ug_words, vms_data.ads: Document VMS qualifiers for -gnatn1/2
switches.

2012-07-16  Bob Duff  <duff@adacore.com>

* sinfo.ads: Minor comment fix.

2012-07-16  Bob Duff  <duff@adacore.com>

* sem_elab.adb (Within_Elaborate_All): Walk the with clauses to
find pragmas Elaborate_All that may be found in the transitive
closure of the dependences.

From-SVN: r189517

gcc/ada/ChangeLog
gcc/ada/sem_elab.adb
gcc/ada/sinfo.ads
gcc/ada/ug_words
gcc/ada/vms_data.ads

index 0ce604e82fa23866f019f8f7643396fd12ee98b5..7634f5974273b31ee955cddbdc177fdd1ca81f8d 100644 (file)
@@ -1,3 +1,18 @@
+2012-07-16  Vasiliy Fofanov  <fofanov@adacore.com>
+
+       * ug_words, vms_data.ads: Document VMS qualifiers for -gnatn1/2
+       switches.
+
+2012-07-16  Bob Duff  <duff@adacore.com>
+
+       * sinfo.ads: Minor comment fix.
+
+2012-07-16  Bob Duff  <duff@adacore.com>
+
+       * sem_elab.adb (Within_Elaborate_All): Walk the with clauses to
+       find pragmas Elaborate_All that may be found in the transitive
+       closure of the dependences.
+
 2012-07-16  Robert Dewar  <dewar@adacore.com>
 
        * exp_pakd.adb, freeze.adb, sem_util.adb, vms_data.ads: Minor
index 4a98db6f1d9e10e206fc3ea9f344f77b92a8e7a8..d1b5f7c6b55a4c9f7e336c77e5f7d2f2c0ba828a 100644 (file)
@@ -325,11 +325,13 @@ package body Sem_Elab is
    --  Given two scopes E1 and E2, returns True if E1 is equal to E2, or is one
    --  of its contained scopes, False otherwise.
 
-   function Within_Elaborate_All (E : Entity_Id) return Boolean;
-   --  Before emitting a warning on a scope E for a missing elaborate_all,
-   --  check whether E may be in the context of a directly visible unit U to
-   --  which the pragma applies. This prevents spurious warnings when the
-   --  called entity is renamed within U.
+   function Within_Elaborate_All
+     (Unit : Unit_Number_Type;
+      E    : Entity_Id) return Boolean;
+   --  Return True if we are within the scope of an Elaborate_All for E, or if
+   --  we are within the scope of an Elaborate_All for some other unit U, and U
+   --  with's E. This prevents spurious warnings when the called entity is
+   --  renamed within U, or in case of generic instances.
 
    --------------------------------------
    -- Activate_Elaborate_All_Desirable --
@@ -831,7 +833,7 @@ package body Sem_Elab is
             end loop;
          end if;
 
-         if Within_Elaborate_All (E_Scope) then
+         if Within_Elaborate_All (Current_Sem_Unit, E_Scope) then
             return;
          end if;
 
@@ -1229,9 +1231,8 @@ package body Sem_Elab is
 
       P := Parent (N);
       while Present (P) loop
-         if Nkind (P) = N_Parameter_Specification
-              or else
-            Nkind (P) = N_Component_Declaration
+         if Nkind_In (P, N_Parameter_Specification,
+                         N_Component_Declaration)
          then
             return;
 
@@ -3282,46 +3283,121 @@ package body Sem_Elab is
    -- Within_Elaborate_All --
    --------------------------
 
-   function Within_Elaborate_All (E : Entity_Id) return Boolean is
-      Item    : Node_Id;
-      Item2   : Node_Id;
-      Elab_Id : Entity_Id;
-      Par     : Node_Id;
+   function Within_Elaborate_All
+     (Unit : Unit_Number_Type;
+      E    : Entity_Id) return Boolean
+   is
+      type Unit_Number_Set is array (Main_Unit .. Last_Unit) of Boolean;
+      pragma Pack (Unit_Number_Set);
 
-   begin
-      Item := First (Context_Items (Cunit (Current_Sem_Unit)));
-      while Present (Item) loop
-         if Nkind (Item) = N_Pragma
-           and then Pragma_Name (Item) = Name_Elaborate_All
-         then
-            --  Return if some previous error on the pragma itself
+      Seen : Unit_Number_Set := (others => False);
+      --  Seen (X) is True after we have seen unit X in the walk. This is used
+      --  to prevent processing the same unit more than once.
 
-            if Error_Posted (Item) then
-               return False;
+      Result : Boolean := False;
+
+      procedure Helper (Unit : Unit_Number_Type);
+      --  This helper procedure does all the work for Within_Elaborate_All. It
+      --  walks the dependency graph, and sets Result to True if it finds an
+      --  appropriate Elaborate_All.
+
+      ------------
+      -- Helper --
+      ------------
+
+      procedure Helper (Unit : Unit_Number_Type) is
+         CU : constant Node_Id := Cunit (Unit);
+
+         Item    : Node_Id;
+         Item2   : Node_Id;
+         Elab_Id : Entity_Id;
+         Par     : Node_Id;
+
+      begin
+         if Seen (Unit) then
+            return;
+         else
+            Seen (Unit) := True;
+         end if;
+
+         --  First, check for Elaborate_Alls on this unit
+
+         Item := First (Context_Items (CU));
+         while Present (Item) loop
+            if Nkind (Item) = N_Pragma
+              and then Pragma_Name (Item) = Name_Elaborate_All
+            then
+               --  Return if some previous error on the pragma itself
+
+               if Error_Posted (Item) then
+                  return;
+               end if;
+
+               Elab_Id :=
+                 Entity
+                   (Expression (First (Pragma_Argument_Associations (Item))));
+
+               if E = Elab_Id then
+                  Result := True;
+                  return;
+               end if;
+
+               Par := Parent (Unit_Declaration_Node (Elab_Id));
+
+               Item2 := First (Context_Items (Par));
+               while Present (Item2) loop
+                  if Nkind (Item2) = N_With_Clause
+                    and then Entity (Name (Item2)) = E
+                    and then not Limited_Present (Item2)
+                  then
+                     Result := True;
+                     return;
+                  end if;
+
+                  Next (Item2);
+               end loop;
             end if;
 
-            Elab_Id :=
-              Entity
-                (Expression (First (Pragma_Argument_Associations (Item))));
+            Next (Item);
+         end loop;
 
-            Par := Parent (Unit_Declaration_Node (Elab_Id));
+         --  Second, recurse on with's. We could do this as part of the above
+         --  loop, but it's probably more efficient to have two loops, because
+         --  the relevant Elaborate_All is likely to be on the initial unit. In
+         --  other words, we're walking the with's breadth-first. This part is
+         --  only necessary in the dynamic elaboration model.
 
-            Item2 := First (Context_Items (Par));
-            while Present (Item2) loop
-               if Nkind (Item2) = N_With_Clause
-                 and then Entity (Name (Item2)) = E
+         if Dynamic_Elaboration_Checks then
+            Item := First (Context_Items (CU));
+            while Present (Item) loop
+               if Nkind (Item) = N_With_Clause
+                 and then not Limited_Present (Item)
                then
-                  return True;
+                  --  Note: the following call to Get_Cunit_Unit_Number does a
+                  --  linear search, which could be slow, but it's OK because
+                  --  we're about to give a warning anyway. Also, there might
+                  --  be hundreds of units, but not millions. If it turns out
+                  --  to be a problem, we could store the Get_Cunit_Unit_Number
+                  --  in each N_Compilation_Unit node, but that would involve
+                  --  rearranging N_Compilation_Unit_Aux to make room.
+
+                  Helper (Get_Cunit_Unit_Number (Library_Unit (Item)));
+
+                  if Result then
+                     return;
+                  end if;
                end if;
 
-               Next (Item2);
+               Next (Item);
             end loop;
          end if;
+      end Helper;
 
-         Next (Item);
-      end loop;
+   --  Start of processing for Within_Elaborate_All
 
-      return False;
+   begin
+      Helper (Unit);
+      return Result;
    end Within_Elaborate_All;
 
 end Sem_Elab;
index cfaa82842c983281e28904f0cd7eb22d5f37c8ee..ec8e9aedeffdada553836e8bd9706019401688ec 100644 (file)
@@ -5796,9 +5796,11 @@ package Sinfo is
       --  Unreferenced_In_Spec (Flag7-Sem)
       --  No_Entities_Ref_In_Spec (Flag8-Sem)
 
-      --  Note: Limited_Present and Limited_View_Installed give support to
-      --        Ada 2005 (AI-50217).
-      --  Similarly, Private_Present gives support to AI-50262.
+      --  Note: Limited_Present and Limited_View_Installed are used to support
+      --  the implementation of Ada 2005 (AI-50217).
+
+      --  Similarly, Private_Present is used to support the implementation of
+      --  Ada 2005 (AI-50262).
 
       ----------------------
       -- With_Type clause --
@@ -5806,8 +5808,9 @@ package Sinfo is
 
       --  This is a GNAT extension, used to implement mutually recursive
       --  types declared in different packages.
+
       --  Note: this is now obsolete. The functionality of this construct
-      --  is now implemented by the Ada 2005 Limited_with_Clause.
+      --  is now implemented by the Ada 2005 limited_with_clause.
 
       ---------------------
       -- 10.2  Body stub --
index 9901b8477a0d0b1d9e6573f4e7807e2de73f4922..29c4ee0f21e1f8591320cf94d48c897eb163bf9f 100644 (file)
@@ -84,6 +84,8 @@ gcc -c          ^ GNAT COMPILE
 -gnatm          ^ /ERROR_LIMIT
 -gnatm2         ^ /ERROR_LIMIT=2
 -gnatn          ^ /INLINE=PRAGMA
+-gnatn1         ^ /INLINE=PRAGMA_LEVEL_1
+-gnatn2         ^ /INLINE=PRAGMA_LEVEL_2
 -gnatN          ^ /INLINE=FULL
 -gnato          ^ /CHECKS=OVERFLOW
 -gnatp          ^ /CHECKS=SUPPRESS_ALL
index e7d93fffd8c5e50da7fe0750ff6caea4f5223089..80c6eaf641cc47e03e222043882682127a8e7c9d 100644 (file)
@@ -1826,8 +1826,13 @@ package VMS_Data is
    --                    (/OPTIMIZE=SOME) or higher (/OPTIMIZE=UNROLL_LOOPS)
    --                    levels of optimization.
    --
-   --        PRAGMA_LEVEL_1/2 not documented ???
+   --        PRAGMA_LEVEL_1
+   --                    Direct control of the level of "Inline" pragmas
+   --                    optimization with moderate inlining across modules.
    --
+   --        PRAGMA_LEVEL_2
+   --                    Direct control of the level of "Inline" pragmas
+   --                    optimization with full inlining across modules.
    --
    --        FULL        Front end inlining. The front end inlining activated
    --                    by this switch is generally more extensive, and quite