]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Wed, 15 Apr 2009 10:46:56 +0000 (12:46 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 15 Apr 2009 10:46:56 +0000 (12:46 +0200)
2009-04-15  Robert Dewar  <dewar@adacore.com>

* frontend.adb (Frontend): Set proper default for
Warn_On_Non_Local_Exception.

* opt.ads (Exception_Handler_Encountered): New flag
(No_Warn_On_Non_Local_Exception): New flag

* par-ch11.adb (P_Exception_Handler): Set Exception_Handler_Encountered

* sem_warn.adb (Set_Warning_Switch): Set No_Warn_On_Non_Local_Exception
(Set_Dot_Warning_Switch): Set No_Warn_On_Non_Local_Exception

2009-04-15  Cyrille Comar  <comar@adacore.com>

* s-tassta.adb, a-exextr.adb, a-elchha.adb
(Ada.Exception.Last_Chance_Handler): Do not print unhandled exception
message when exception traces are active since it would generate
redundant information.
(Exception_Traces.Notify_Exception): put message output by a critical
section to avoid unsynchronized output.
(Trace_Unhandled_Exception_In_Task): put message output by a critical
section to avoid unsynchronized output.

2009-04-15  Emmanuel Briot  <briot@adacore.com>

* g-comlin.adb, prj-tree.adb, prj-tree.ads, prj.adb, prj.ads
(Free): New subprogram.

From-SVN: r146100

13 files changed:
gcc/ada/ChangeLog
gcc/ada/a-elchha.adb
gcc/ada/a-exextr.adb
gcc/ada/frontend.adb
gcc/ada/g-comlin.adb
gcc/ada/opt.ads
gcc/ada/par-ch11.adb
gcc/ada/prj-tree.adb
gcc/ada/prj-tree.ads
gcc/ada/prj.adb
gcc/ada/prj.ads
gcc/ada/s-tassta.adb
gcc/ada/sem_warn.adb

index cb212e69e0591921b4fc7f5a4c5972d227ddf41d..99395eb41910ca283efc62052ae79e89e1235027 100644 (file)
@@ -1,3 +1,32 @@
+2009-04-15  Robert Dewar  <dewar@adacore.com>
+
+       * frontend.adb (Frontend): Set proper default for
+       Warn_On_Non_Local_Exception.
+
+       * opt.ads (Exception_Handler_Encountered): New flag
+       (No_Warn_On_Non_Local_Exception): New flag
+
+       * par-ch11.adb (P_Exception_Handler): Set Exception_Handler_Encountered
+
+       * sem_warn.adb (Set_Warning_Switch): Set No_Warn_On_Non_Local_Exception
+       (Set_Dot_Warning_Switch): Set No_Warn_On_Non_Local_Exception
+
+2009-04-15  Cyrille Comar  <comar@adacore.com>
+
+       * s-tassta.adb, a-exextr.adb, a-elchha.adb
+       (Ada.Exception.Last_Chance_Handler): Do not print unhandled exception
+       message when exception traces are active since it would generate
+       redundant information.
+       (Exception_Traces.Notify_Exception): put message output by a critical
+       section to avoid unsynchronized output.
+       (Trace_Unhandled_Exception_In_Task): put message output by a critical
+       section to avoid unsynchronized output.
+
+2009-04-15  Emmanuel Briot  <briot@adacore.com>
+
+       * g-comlin.adb, prj-tree.adb, prj-tree.ads, prj.adb, prj.ads
+       (Free): New subprogram.
+
 2009-04-15  Hristian Kirtchev  <kirtchev@adacore.com>
 
        * a-calend.adb: Add new constant Nanos_In_Four_Years.
index caa89ffb7b5e0c2b6f2c13907b156f13fa4bc591..087e22f4ffbf4dca6ece9b429f95d02aa049b30a 100644 (file)
@@ -79,7 +79,7 @@ begin
    System.Soft_Links.Task_Termination_Handler :=
      System.Soft_Links.Task_Termination_NT'Access;
 
-   --  Let's shutdown the runtime now. The rest of the procedure needs to be
+   --  We shutdown the runtime now. The rest of the procedure needs to be
    --  careful not to use anything that would require runtime support. In
    --  particular, functions returning strings are banned since the sec stack
    --  is no longer functional. This is particularly important to note for the
@@ -93,11 +93,16 @@ begin
 
    System.Standard_Library.Adafinal;
 
+   --  Print a message only when exception traces are not active
+
+   if Exception_Trace /= RM_Convention then
+      null;
+
    --  Check for special case of raising _ABORT_SIGNAL, which is not
    --  really an exception at all. We recognize this by the fact that
    --  it is the only exception whose name starts with underscore.
 
-   if To_Ptr (Except.Id.Full_Name) (1) = '_' then
+   elsif To_Ptr (Except.Id.Full_Name) (1) = '_' then
       To_Stderr (Nline);
       To_Stderr ("Execution terminated by abort of environment task");
       To_Stderr (Nline);
index 967a54b10997d31b31d9876b81457be18c8787da..2ea9a3ad1e550c7a426f4f88ffbfb968984cca9d 100644 (file)
@@ -101,9 +101,13 @@ package body Exception_Traces is
 
       if not Excep.Id.Not_Handled_By_Others
         and then
-        (Exception_Trace = Every_Raise
-          or else (Exception_Trace = Unhandled_Raise and then Is_Unhandled))
+          (Exception_Trace = Every_Raise
+            or else (Exception_Trace = Unhandled_Raise and then Is_Unhandled))
       then
+         --  Exception trace messages need to be protected when several tasks
+         --  can issue them at the same time.
+
+         Lock_Task.all;
          To_Stderr (Nline);
 
          if Is_Unhandled then
@@ -113,6 +117,7 @@ package body Exception_Traces is
          To_Stderr ("Exception raised");
          To_Stderr (Nline);
          To_Stderr (Tailored_Exception_Information (Excep.all));
+         Unlock_Task.all;
       end if;
 
       --  Call the user-specific actions
index 8f16a11786680385b5ea34848c7430313e46b822..5fd28221533b4bdf230ad6b8f522d712eb5eb2e2 100644 (file)
@@ -43,6 +43,8 @@ with Opt;      use Opt;
 with Osint;
 with Par;
 with Prepcomp;
+with Restrict; use Restrict;
+with Rident;   use Rident;
 with Rtsfind;
 with Sprint;
 with Scn;      use Scn;
@@ -64,12 +66,12 @@ procedure Frontend is
    --  Gather configuration pragmas
 
 begin
-   --  Carry out package initializations. These are initializations which
-   --  might logically be performed at elaboration time, were it not for
-   --  the fact that we may be doing things more than once in the big loop
-   --  over files. Like elaboration, the order in which these calls are
-   --  made is in some cases important. For example, Lib cannot be
-   --  initialized until Namet, since it uses names table entries.
+   --  Carry out package initializations. These are initializations which might
+   --  logically be performed at elaboration time, were it not for the fact
+   --  that we may be doing things more than once in the big loop over files.
+   --  Like elaboration, the order in which these calls are made is in some
+   --  cases important. For example, Lib cannot be initialized until Namet,
+   --  since it uses names table entries.
 
    Rtsfind.Initialize;
    Atree.Initialize;
@@ -275,6 +277,17 @@ begin
       end;
    end if;
 
+   --  If we have restriction No_Exception_Propagation, and we did not have
+   --  an explicit switch turning off Warn_On_Local_Exception, then turn on
+   --  this warning by default if we have encountered an exception handler.
+
+   if Restriction_Active (No_Exception_Propagation)
+     and then not No_Warn_On_Non_Local_Exception
+     and then Exception_Handler_Encountered
+   then
+      Warn_On_Non_Local_Exception := True;
+   end if;
+
    --  Now on to the semantics. Skip if in syntax only mode
 
    if Operating_Mode /= Check_Syntax then
index 307f890750e22f3f64074fa55d524ae0b7097586..9564ff2d75411e82d3cfc313b80cb3e78c465fcb 100644 (file)
@@ -2449,6 +2449,8 @@ package body GNAT.Command_Line is
          Free (Config.Aliases);
          Free (Config.Expansions);
          Free (Config.Prefixes);
+         Free (Config.Sections);
+         Free (Config.Switches);
          Unchecked_Free (Config);
       end if;
    end Free;
index 71bcb19871b11cb4c81d285ce8e316a3ae7dd6e8..547afefb5f5338f6d5c7962c0df6b3695bb94873 100644 (file)
@@ -415,6 +415,12 @@ package Opt is
    --  to make a single long message, and then this message is split up into
    --  multiple lines not exceeding the specified length. Set by -gnatj=nn.
 
+   Exception_Handler_Encountered : Boolean := False;
+   --  GNAT
+   --  This flag is set true if the parser encounters an exception handler.
+   --  It is used to set Warn_On_Exception_Propagation True if the restriction
+   --  No_Exception_Propagation is set.
+
    Exception_Locations_Suppressed : Boolean := False;
    --  GNAT
    --  This flag is set True if a Suppress_Exception_Locations configuration
@@ -1309,7 +1315,15 @@ package Opt is
    --  Set to True to generate warnings for non-local exception raises and also
    --  handlers that can never handle a local raise. This warning is only ever
    --  generated if pragma Restrictions (No_Exception_Propagation) is set. The
-   --  default is not to generate the warnings even if the restriction is set.
+   --  default is not to generate the warnings except that if the source has
+   --  at least one exception, and this restriction is set, and the warning
+   --  was not explicitly turned off, then it is turned on by default.
+
+   No_Warn_On_Non_Local_Exception : Boolean := False;
+   --  GNAT
+   --  This is set to True if the above warning is explicitly suppressed. We
+   --  use this to avoid turning it on by default when No_Exception_Propagation
+   --  restriction is set.
 
    Warn_On_Obsolescent_Feature : Boolean := False;
    --  GNAT
index 412456e1a7e17269b42d805c1de204da15b6b56b..14129bc62308c1246c6b1ad22c7d24c0278c3f5b 100644 (file)
@@ -92,6 +92,7 @@ package body Ch11 is
       Choice_Param_Node : Node_Id;
 
    begin
+      Exception_Handler_Encountered := True;
       Handler_Node := New_Node (N_Exception_Handler, Token_Ptr);
       Set_Local_Raise_Statements (Handler_Node, No_Elist);
 
index 0f9f5de986fbd9828e0fcfec3956c783e86d99d9..61a329fcb027fd8548003dec07c7985d3530ae99 100644 (file)
@@ -23,6 +23,7 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
+with Ada.Unchecked_Deallocation;
 with Prj.Err;
 
 package body Prj.Tree is
@@ -984,6 +985,21 @@ package body Prj.Tree is
       Projects_Htable.Reset (Tree.Projects_HT);
    end Initialize;
 
+   ----------
+   -- Free --
+   ----------
+
+   procedure Free (Prj : in out Project_Node_Tree_Ref) is
+      procedure Unchecked_Free is new Ada.Unchecked_Deallocation
+        (Project_Node_Tree_Data, Project_Node_Tree_Ref);
+   begin
+      if Prj /= null then
+         Project_Node_Table.Free (Prj.Project_Nodes);
+         Projects_Htable.Reset (Prj.Projects_HT);
+         Unchecked_Free (Prj);
+      end if;
+   end Free;
+
    -------------------------------
    -- Is_Followed_By_Empty_Line --
    -------------------------------
index 94526660e202f73b8d7703d2ce64a63f592262c2..75961ff08e1aec3b7b7f6cbb7f7b3dfaf2c6e18a 100644 (file)
@@ -1300,6 +1300,9 @@ package Prj.Tree is
    end record;
    --  The data for a project node tree
 
+   procedure Free (Prj : in out Project_Node_Tree_Ref);
+   --  Free memory used by Prj
+
 private
    type Comment_Array is array (Positive range <>) of Comment_Data;
    type Comments_Ptr is access Comment_Array;
index ca804d9b0a86a066c6326ffe1c2b2e4fdb719a25..6c26bc182a35853476c4b94451ed2cc48e234b9e 100644 (file)
@@ -24,6 +24,7 @@
 ------------------------------------------------------------------------------
 
 with Ada.Characters.Handling; use Ada.Characters.Handling;
+with Ada.Unchecked_Deallocation;
 
 with Debug;
 with Output;   use Output;
@@ -826,17 +827,51 @@ package body Prj is
       end if;
    end Register_Default_Naming_Scheme;
 
+   ----------
+   -- Free --
+   ----------
+
+   procedure Free (Tree : in out Project_Tree_Ref) is
+      procedure Unchecked_Free is new Ada.Unchecked_Deallocation
+        (Project_Tree_Data, Project_Tree_Ref);
+   begin
+      if Tree /= null then
+         Language_Data_Table.Free (Tree.Languages_Data);
+         Name_List_Table.Free (Tree.Name_Lists);
+         String_Element_Table.Free (Tree.String_Elements);
+         Variable_Element_Table.Free (Tree.Variable_Elements);
+         Array_Element_Table.Free (Tree.Array_Elements);
+         Array_Table.Free (Tree.Arrays);
+         Package_Table.Free (Tree.Packages);
+         Project_List_Table.Free (Tree.Project_Lists);
+         Project_Table.Free (Tree.Projects);
+         Source_Data_Table.Free (Tree.Sources);
+         Alternate_Language_Table.Free (Tree.Alt_Langs);
+         Unit_Table.Free (Tree.Units);
+         Units_Htable.Reset (Tree.Units_HT);
+         Files_Htable.Reset (Tree.Files_HT);
+         Source_Paths_Htable.Reset (Tree.Source_Paths_HT);
+         Unit_Sources_Htable.Reset (Tree.Unit_Sources_HT);
+
+         --  Private part
+
+         Naming_Table.Free (Tree.Private_Part.Namings);
+         Path_File_Table.Free (Tree.Private_Part.Path_Files);
+         Source_Path_Table.Free (Tree.Private_Part.Source_Paths);
+         Object_Path_Table.Free (Tree.Private_Part.Object_Paths);
+
+         --  Naming data (nothing to free ?)
+         null;
+
+         Unchecked_Free (Tree);
+      end if;
+   end Free;
+
    -----------
    -- Reset --
    -----------
 
    procedure Reset (Tree : Project_Tree_Ref) is
-
-      --  Def_Lang : constant Name_Node :=
-      --             (Name => Name_Ada,
-      --              Next => No_Name_List);
-      --  Why is the above commented out ???
-
    begin
       Prj.Env.Initialize;
 
index adc574723292e342a925f4d8dc9762ea7e6475a4..0d506338055507fee32b52e1e36b6d93c21093e5 100644 (file)
@@ -116,6 +116,9 @@ package Prj is
 
    No_Project_Tree : constant Project_Tree_Ref;
 
+   procedure Free (Tree : in out Project_Tree_Ref);
+   --  Free memory associated with the tree
+
    function Default_Ada_Spec_Suffix return File_Name_Type;
    pragma Inline (Default_Ada_Spec_Suffix);
    --  The name for the standard GNAT suffix for Ada spec source file name
index eaa6ff0b43028117c75b2121522408b0cd74b486..836f332334caf6c21826409547b12de016bad636 100644 (file)
@@ -1388,6 +1388,7 @@ package body System.Tasking.Stages is
       --  unwound. The common notification routine has been called at the
       --  raise point already.
 
+      Initialization.Task_Lock (Self_Id);
       To_Stderr ("task ");
 
       if Self_Id.Common.Task_Image_Len /= 0 then
@@ -1400,6 +1401,7 @@ package body System.Tasking.Stages is
       To_Stderr (" terminated by unhandled exception");
       To_Stderr ((1 => ASCII.LF));
       To_Stderr (Tailored_Exception_Information (Excep.all));
+      Initialization.Task_Unlock (Self_Id);
    end Trace_Unhandled_Exception_In_Task;
 
    ------------------------------------
index 3550392f872711d1c6cc3ce08099087a7181b917..29a850a6e0a123e20ecff3c9b50f44ea6e0453c3 100644 (file)
@@ -3006,6 +3006,7 @@ package body Sem_Warn is
 
          when 'X' =>
             Warn_On_Non_Local_Exception         := False;
+            No_Warn_On_Non_Local_Exception      := True;
 
          when others =>
             return False;
@@ -3079,6 +3080,8 @@ package body Sem_Warn is
             Warn_On_Unrepped_Components         := False;
             Warn_On_Warnings_Off                := False;
 
+            No_Warn_On_Non_Local_Exception      := True;
+
          when 'b' =>
             Warn_On_Bad_Fixed_Value             := True;