]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Mon, 20 Jan 2014 15:29:06 +0000 (16:29 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 20 Jan 2014 15:29:06 +0000 (16:29 +0100)
2014-01-20  Pascal Obry  <obry@adacore.com>

* s-win32.ads (FreeLibrary): New import.

2014-01-20  Robert Dewar  <dewar@adacore.com>

* sem_res.adb, sem_cat.adb: Minor reformatting.
* sem_ch11.adb (Analyze_Raise_Statement): Only give warning about
assigning to OUT parameters for the current subprogram scope.
* exp_ch4.adb: Minor reformatting.

2014-01-20  Ed Schonberg  <schonberg@adacore.com>

* exp_ch4.adb (Process_Transient_Object,
Find_Enclosing_Contexts): If the top-level if-expression that
generated the transient object is an actual in a call, the proper
Hook_Context is a construct enclosing the call.
* einfo.ads: Indicate that Related_Expression is used to link a
loop variable to the container expression over which the loop
takes place.
(Analyze_Iterator_Specification): Set the Related_Expression of
the loop variable in a container element iterator.
(Note_Possible_Modification): If the variable is the loop
variable in a container element iterator, indicate that the
enclosing container is also modified.

2014-01-20  Hristian Kirtchev  <kirtchev@adacore.com>

* aspects.adb (Move_Or_Merge_Aspects): Reimplemented.

From-SVN: r206824

gcc/ada/ChangeLog
gcc/ada/aspects.adb
gcc/ada/aspects.ads
gcc/ada/einfo.ads
gcc/ada/exp_ch4.adb
gcc/ada/s-win32.ads
gcc/ada/sem_cat.adb
gcc/ada/sem_ch11.adb
gcc/ada/sem_ch5.adb
gcc/ada/sem_res.adb
gcc/ada/sem_util.adb

index cc097b2e7b923756acb0b2a5fde89c26de753de4..41edf88e47a42b3c9f95d0ca86dd2da08006b1f5 100644 (file)
@@ -1,3 +1,33 @@
+2014-01-20  Pascal Obry  <obry@adacore.com>
+
+       * s-win32.ads (FreeLibrary): New import.
+
+2014-01-20  Robert Dewar  <dewar@adacore.com>
+
+       * sem_res.adb, sem_cat.adb: Minor reformatting.
+       * sem_ch11.adb (Analyze_Raise_Statement): Only give warning about
+       assigning to OUT parameters for the current subprogram scope.
+       * exp_ch4.adb: Minor reformatting.
+
+2014-01-20  Ed Schonberg  <schonberg@adacore.com>
+
+       * exp_ch4.adb (Process_Transient_Object,
+       Find_Enclosing_Contexts): If the top-level if-expression that
+       generated the transient object is an actual in a call, the proper
+       Hook_Context is a construct enclosing the call.
+       * einfo.ads: Indicate that Related_Expression is used to link a
+       loop variable to the container expression over which the loop
+       takes place.
+       (Analyze_Iterator_Specification): Set the Related_Expression of
+       the loop variable in a container element iterator.
+       (Note_Possible_Modification): If the variable is the loop
+       variable in a container element iterator, indicate that the
+       enclosing container is also modified.
+
+2014-01-20  Hristian Kirtchev  <kirtchev@adacore.com>
+
+       * aspects.adb (Move_Or_Merge_Aspects): Reimplemented.
+
 2014-01-20  Robert Dewar  <dewar@adacore.com>
 
        * s-taasde.ads, gnat_ugn.texi, s-tadeca.adb, sem_res.adb, s-tadeca.ads:
index 091af77ef77e156f4ab7b13b5d66233cc7f798eb..4e173522f5e920209de991c6676f4a3a10d9afe5 100644 (file)
@@ -310,22 +310,86 @@ package body Aspects is
    ---------------------------
 
    procedure Move_Or_Merge_Aspects (From : Node_Id; To : Node_Id) is
-   begin
-      if Has_Aspects (From) then
+      procedure Relocate_Aspect (Asp : Node_Id);
+      --  Asp denotes an aspect specification of node From. Relocate the Asp to
+      --  the aspect specifications of node To (if any).
 
-         --  Merge the aspects of From into To. Make sure that From has no
-         --  aspects after the merge takes place.
+      ---------------------
+      -- Relocate_Aspect --
+      ---------------------
 
+      procedure Relocate_Aspect (Asp : Node_Id) is
+         Asps : List_Id;
+
+      begin
          if Has_Aspects (To) then
-            Append_List
-              (List => Aspect_Specifications (From),
-               To   => Aspect_Specifications (To));
-            Remove_Aspects (From);
+            Asps := Aspect_Specifications (To);
 
-         --  Otherwise simply move the aspects
+         --  Create a new aspect specification list for node To
 
          else
-            Move_Aspects (From => From, To => To);
+            Asps := New_List;
+            Set_Aspect_Specifications (To, Asps);
+            Set_Has_Aspects (To);
+         end if;
+
+         --  Remove the aspect from node From's aspect specifications and
+         --  append it to node To.
+
+         Remove (Asp);
+         Append (Asp, Asps);
+      end Relocate_Aspect;
+
+      --  Local variables
+
+      Asp      : Node_Id;
+      Asp_Id   : Aspect_Id;
+      Next_Asp : Node_Id;
+
+   --  Start of processing for Move_Or_Merge_Aspects
+
+   begin
+      if Has_Aspects (From) then
+         Asp := First (Aspect_Specifications (From));
+         while Present (Asp) loop
+
+            --  Store the next aspect now as a potential relocation will alter
+            --  the contents of the list.
+
+            Next_Asp := Next (Asp);
+
+            --  When moving or merging aspects from a subprogram body stub that
+            --  also acts as a spec, relocate only those aspects that may apply
+            --  to a body [stub]. Note that a precondition must also be moved
+            --  to the proper body as the pre/post machinery expects it to be
+            --  there.
+
+            if Nkind (From) = N_Subprogram_Body_Stub
+              and then No (Corresponding_Spec_Of_Stub (From))
+            then
+               Asp_Id := Get_Aspect_Id (Asp);
+
+               if Aspect_On_Body_Or_Stub_OK (Asp_Id)
+                 or else Asp_Id = Aspect_Pre
+                 or else Asp_Id = Aspect_Precondition
+               then
+                  Relocate_Aspect (Asp);
+               end if;
+
+            --  Default case - relocate the aspect to its new owner
+
+            else
+               Relocate_Aspect (Asp);
+            end if;
+
+            Asp := Next_Asp;
+         end loop;
+
+         --  The relocations may have left node From's aspect specifications
+         --  list empty. If this is the case, simply remove the aspects.
+
+         if Is_Empty_List (Aspect_Specifications (From)) then
+            Remove_Aspects (From);
          end if;
       end if;
    end Move_Or_Merge_Aspects;
index 2fd4b451bb05d3bd88997ecb9c0b60e7ec4ef032..2f318638e8a2e0c79cd9079d24aed5557e63c56c 100644 (file)
@@ -779,7 +779,9 @@ package Aspects is
    procedure Move_Or_Merge_Aspects (From : Node_Id; To : Node_Id);
    --  Relocate the aspect specifications of node From to node To. If To has
    --  aspects, the aspects of From are added to the aspects of To. If From has
-   --  no aspects, the routine has no effect.
+   --  no aspects, the routine has no effect. When From denotes a subprogram
+   --  body stub that also acts as a spec, the only aspects relocated to node
+   --  To are those from table Aspect_On_Body_Or_Stub_OK and preconditions.
 
    function Permits_Aspect_Specifications (N : Node_Id) return Boolean;
    --  Returns True if the node N is a declaration node that permits aspect
index 59ab153555fde2da06d80874a473f008a63ce1f8..548090e83518721c793458a99592d8b82af976fa 100644 (file)
@@ -3578,10 +3578,14 @@ package Einfo is
 --       only for type-related error messages.
 
 --    Related_Expression (Node24)
---       Defined in variables and types. Set only for internally generated
---       entities, where it may be used to denote the source expression whose
+--       Defined in variables and types. When Set for internally generated
+--       entities, it may be used to denote the source expression whose
 --       elaboration created the variable declaration. If set, it is used
---       for generating clearer messages from CodePeer.
+--       for generating clearer messages from CodePeer. It is used on source
+--       entities that are variables in iterator specifications, to provide
+--       a link to the container that is the domain of iteration. This allows
+--       for better cross-reference information when the loop modifies elements
+--       of the container, and suppresses spurious warnings.
 --
 --       Shouldn't it also be used for the same purpose in errout? It seems
 --       odd to have two mechanisms here???
index f47406054af9d243f1db80270de89284dc944cde..16ff6250588b89a8da19bc235dfcf5c28177169d 100644 (file)
@@ -12194,7 +12194,8 @@ package body Exp_Ch4 is
 
             --  The topmost case or if expression is now recovered, but it may
             --  still not be the correct place to add generated code. Climb to
-            --  find a parent that is part of a declarative or statement list.
+            --  find a parent that is part of a declarative or statement list,
+            --  and is not a list of actuals in a call.
 
             Par := Top;
             while Present (Par) loop
@@ -12203,6 +12204,11 @@ package body Exp_Ch4 is
                                              N_Discriminant_Association,
                                              N_Parameter_Association,
                                              N_Pragma_Argument_Association)
+                 and then not Nkind_In
+                                (Parent (Par), N_Function_Call,
+                                               N_Procedure_Call_Statement,
+                                               N_Entry_Call_Statement)
+
                then
                   Hook_Context := Par;
                   goto Hook_Context_Found;
index 4c92ea5ede7422135a3dda04065a6e4a5039f944..6fafd526a439110065b7249dfec14ce9c1296a72 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 2008-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 2008-2013, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -336,4 +336,7 @@ package System.Win32 is
       nSize      : DWORD) return DWORD;
    pragma Import (Stdcall, GetModuleFileName, "GetModuleFileNameA");
 
+   function FreeLibrary (hModule : HANDLE) return BOOL;
+   pragma Import (Stdcall, FreeLibrary, "FreeLibrary");
+
 end System.Win32;
index 92979c7ab16bfdc21a67cfe79f93e30fd9dcce13..69cb626dd067a7f545a1618e9b490851b337add4 100644 (file)
@@ -1226,6 +1226,7 @@ package body Sem_Cat is
                   --  given for the private type.
 
                   if Relaxed_RM_Semantics then
+
                      --  In relaxed mode, do not issue these messages, this
                      --  is basically similar to the GNAT_Mode test below.
 
index a397edfb40e0d4eb24a9bae46797f84b06eb47f6..f0898bfa0df4c2cd66cc9b051374a2afe9df7ee3 100644 (file)
@@ -37,6 +37,7 @@ with Restrict; use Restrict;
 with Rident;   use Rident;
 with Rtsfind;  use Rtsfind;
 with Sem;      use Sem;
+with Sem_Aux;  use Sem_Aux;
 with Sem_Ch5;  use Sem_Ch5;
 with Sem_Ch8;  use Sem_Ch8;
 with Sem_Ch13; use Sem_Ch13;
@@ -533,6 +534,13 @@ package body Sem_Ch11 is
                if Is_Scalar_Type (Etype (L))
                  and then Is_Entity_Name (L)
                  and then Is_Formal (Entity (L))
+
+                 --  Do this only for parameters to the current subprogram.
+                 --  This avoids some false positives for the nested case.
+
+                 and then Nearest_Dynamic_Scope (Current_Scope) =
+                            Scope (Entity (L))
+
                then
                   --  Don't give warning if we are covered by an exception
                   --  handler, since this may result in false positives, since
index 4f900129c4e71d938f8ea1e58a275dcecb8e4425..3b0d1369abd761c1266499401aee4b7ead03a634 100644 (file)
@@ -1695,6 +1695,13 @@ package body Sem_Ch5 is
 
       Set_Ekind (Def_Id, E_Variable);
 
+      --  Provide a link between the iterator variable and the container,
+      --  for subequent use in cross-reference and modification information.
+
+      if Of_Present (N) then
+         Set_Related_Expression (Def_Id, Iter_Name);
+      end if;
+
       --  If the domain of iteration is an expression, create a declaration for
       --  it, so that finalization actions are introduced outside of the loop.
       --  The declaration must be a renaming because the body of the loop may
index 6861f1a00b0cc37227e85381ca41b1cd5085dafc..07a3c4a49805c908bf88f7c5218f7f4e0497f9f0 100644 (file)
@@ -2178,17 +2178,17 @@ package body Sem_Res is
 
                      elsif not Comes_From_Predefined_Lib_Unit (Seen) then
 
-                        --  Previous interpretation must be discarded.
+                        --  Previous interpretation must be discarded
 
-                        I1    := I;
-                        Seen  := It.Nam;
+                        I1 := I;
+                        Seen := It.Nam;
                         Expr_Type := It.Typ;
                         Set_Entity (N, Seen);
                         goto Continue;
                      end if;
                   end if;
 
-                  --  Otherwise apply further disambiguation steps.
+                  --  Otherwise apply further disambiguation steps
 
                   Error_Msg_Sloc := Sloc (Seen);
                   It1 := Disambiguate (N, I1, I, Typ);
index d342e347290e8706bc080de15cd9e5543b17f259..e9722a3f076a6a0177be149036d43e5ad3cbce42 100644 (file)
@@ -13074,6 +13074,18 @@ package body Sem_Util is
                  and then Present (Renamed_Object (Ent))
                then
                   Exp := Renamed_Object (Ent);
+
+                  --  If the entity is the loop variable in an iteration over
+                  --  a container, retrieve container expression to indicate
+                  --  possible modificastion.
+
+                  if Present (Related_Expression (Ent))
+                    and then Nkind (Parent (Related_Expression (Ent))) =
+                      N_Iterator_Specification
+                  then
+                     Exp := Original_Node (Related_Expression (Ent));
+                  end if;
+
                   goto Continue;
 
                --  The expression may be the renaming of a subcomponent of an