[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Wed, 27 Apr 2016 12:26:50 +0000 (14:26 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 27 Apr 2016 12:26:50 +0000 (14:26 +0200)
2016-04-27  Arnaud Charlet  <charlet@adacore.com>

* s-rident.ads: Make No_Implicit_Loops non partition wide.

2016-04-27  Arnaud Charlet  <charlet@adacore.com>

* sem_ch11.adb (Analyze_Handled_Statements): check useless
assignments also in entries and task bodies, not only in
procedures and declaration blocks.
* sem_ch5.adb (Analyze_Block_Statement): check useless
assignements in declaration blocks as part of processing their
handled statement sequence, just like it was done for procedures
and now is also done for entries and task bodies.
* sem_warn.adb (Warn_On_Useless_Assignment): detect boundries
of entries and task bodies just like of procedures.

2016-04-27  Hristian Kirtchev  <kirtchev@adacore.com>

* sem_util.adb (Is_Volatile_Function): Recognize
a function declared within a protected type as well as the
protected/unprotected version of a function.

From-SVN: r235491

gcc/ada/ChangeLog
gcc/ada/s-rident.ads
gcc/ada/sem_ch11.adb
gcc/ada/sem_ch5.adb
gcc/ada/sem_util.adb
gcc/ada/sem_warn.adb

index 75f690448b59b4107efa5b68a68c86874071a2c1..b04b513777c74c1cbd4da43c57f3d69943cabc36 100644 (file)
@@ -1,3 +1,25 @@
+2016-04-27  Arnaud Charlet  <charlet@adacore.com>
+
+       * s-rident.ads: Make No_Implicit_Loops non partition wide.
+
+2016-04-27  Arnaud Charlet  <charlet@adacore.com>
+
+       * sem_ch11.adb (Analyze_Handled_Statements): check useless
+       assignments also in entries and task bodies, not only in
+       procedures and declaration blocks.
+       * sem_ch5.adb (Analyze_Block_Statement): check useless
+       assignements in declaration blocks as part of processing their
+       handled statement sequence, just like it was done for procedures
+       and now is also done for entries and task bodies.
+       * sem_warn.adb (Warn_On_Useless_Assignment): detect boundries
+       of entries and task bodies just like of procedures.
+
+2016-04-27  Hristian Kirtchev  <kirtchev@adacore.com>
+
+       * sem_util.adb (Is_Volatile_Function): Recognize
+       a function declared within a protected type as well as the
+       protected/unprotected version of a function.
+
 2016-04-27  Bob Duff  <duff@adacore.com>
 
        * exp_ch3.adb (Expand_N_Object_Declaration): Rewrite an object
index f8ecb6743016f320e0df79dbc1a20c969e01595a..4f36b460b6a281bde6e22758824b02a163b8eac3 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2015, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2016, 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- --
@@ -121,7 +121,6 @@ package System.Rident is
       No_Implicit_Heap_Allocations,              -- (RM D.8(8), H.4(3))
       No_Implicit_Task_Allocations,              -- GNAT
       No_Implicit_Protected_Object_Allocations,  -- GNAT
-      No_Implicit_Loops,                         -- GNAT
       No_Initialize_Scalars,                     -- GNAT
       No_Local_Allocators,                       -- (RM H.4(8))
       No_Local_Timing_Events,                    -- (RM D.7(10.2/2))
@@ -179,6 +178,7 @@ package System.Rident is
       No_Implementation_Restrictions,            -- GNAT
       No_Implementation_Units,                   -- Ada 2012 AI-242
       No_Implicit_Aliasing,                      -- GNAT
+      No_Implicit_Loops,                         -- GNAT
       No_Elaboration_Code,                       -- GNAT
       No_Obsolescent_Features,                   -- Ada 2005 AI-368
       No_Wide_Characters,                        -- GNAT
index e03ec1cb4ea9b92f1daf3052a904c64842a7fb52..381972d1fb4e72a024ba42ae510ed0943d597418 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2015, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2016, 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- --
@@ -417,14 +417,15 @@ package body Sem_Ch11 is
 
       Analyze_Statements (Statements (N));
 
-      --  If the current scope is a subprogram, then this is the right place to
-      --  check for hanging useless assignments from the statement sequence of
-      --  the subprogram body. Skip this in the body of a postcondition,
-      --  since in that case there are no source references, and we need to
-      --  preserve deferred references from the enclosing scope.
+      --  If the current scope is a subprogram, entry or task body or declare
+      --  block then this is the right place to check for hanging useless
+      --  assignments from the statement sequence. Skip this in the body of a
+      --  postcondition, since in that case there are no source references, and
+      --  we need to preserve deferred references from the enclosing scope.
 
-      if Is_Subprogram (Current_Scope)
-         and then Chars (Current_Scope) /= Name_uPostconditions
+      if ((Is_Subprogram (Current_Scope) or else Is_Entry (Current_Scope))
+           and then Chars (Current_Scope) /= Name_uPostconditions)
+         or else Ekind_In (Current_Scope, E_Block, E_Task_Type)
       then
          Warn_On_Useless_Assignments (Current_Scope);
       end if;
index 9b4d589eb0fb40e05a09cc182305c9669d64d78c..5dcdf445c8120fb7fe7eaea9bdbc7a0da8b20d74 100644 (file)
@@ -1062,7 +1062,6 @@ package body Sem_Ch5 is
          end if;
 
          Check_References (Ent);
-         Warn_On_Useless_Assignments (Ent);
          End_Scope;
 
          if Unblocked_Exit_Count = 0 then
index 21157ec9086a2ae402f1968ca09c31a4cb4f59a8..46baf0bc8820cfad368575bb0f41bc50aa84ff57 100644 (file)
@@ -13377,14 +13377,14 @@ package body Sem_Util is
 
             return
               Pref = Obj_Ref
-              and then Present (Etype (Pref))
-              and then Is_Protected_Type (Etype (Pref))
-              and then Is_Entity_Name (Subp)
-              and then Present (Entity (Subp))
-              and then Ekind_In (Entity (Subp), E_Entry,
-                                 E_Entry_Family,
-                                 E_Function,
-                                 E_Procedure);
+                and then Present (Etype (Pref))
+                and then Is_Protected_Type (Etype (Pref))
+                and then Is_Entity_Name (Subp)
+                and then Present (Entity (Subp))
+                and then Ekind_In (Entity (Subp), E_Entry,
+                                                  E_Entry_Family,
+                                                  E_Function,
+                                                  E_Procedure);
          else
             return False;
          end if;
@@ -14954,17 +14954,11 @@ package body Sem_Util is
 
    function Is_Volatile_Function (Func_Id : Entity_Id) return Boolean is
    begin
-      --  The caller must ensure that Func_Id denotes a function
-
       pragma Assert (Ekind_In (Func_Id, E_Function, E_Generic_Function));
 
-      --  A protected function is automatically volatile
+      --  A function declared within a protected type is volatile
 
-      if Is_Primitive (Func_Id)
-        and then Present (First_Formal (Func_Id))
-        and then Is_Protected_Type (Etype (First_Formal (Func_Id)))
-        and then Etype (First_Formal (Func_Id)) = Scope (Func_Id)
-      then
+      if Is_Protected_Type (Scope (Func_Id)) then
          return True;
 
       --  An instance of Ada.Unchecked_Conversion is a volatile function if
index 09f9ac8858d08d1bcd54c5b96bdafd4e402b6384..c8bf23a6ec6f0c7ce870e1bdea83a1aa41ade12d 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1999-2015, Free Software Foundation, Inc.         --
+--          Copyright (C) 1999-2016, 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- --
@@ -4297,8 +4297,10 @@ package body Sem_Warn is
 
             --  When we hit a package/subprogram body, issue warning and exit
 
-            elsif Nkind (P) = N_Subprogram_Body
-              or else Nkind (P) = N_Package_Body
+            elsif Nkind_In (P, N_Entry_Body,
+                               N_Package_Body,
+                               N_Subprogram_Body,
+                               N_Task_Body)
             then
                --  Case of assigned value never referenced
 
@@ -4376,8 +4378,10 @@ package body Sem_Warn is
                   --  not generate the warning, since the variable in question
                   --  may be accessed after an exception in the outer block.
 
-                  if Nkind (Parent (P)) /= N_Subprogram_Body
-                    and then Nkind (Parent (P)) /= N_Package_Body
+                  if not Nkind_In (Parent (P), N_Entry_Body,
+                                               N_Package_Body,
+                                               N_Subprogram_Body,
+                                               N_Task_Body)
                   then
                      Set_Last_Assignment (Ent, Empty);
                      return;