restrict.ads, [...] (No_Exception_Handlers_Set): Only return true if configurable...
authorArnaud Charlet <charlet@gcc.gnu.org>
Wed, 6 Jun 2007 10:41:12 +0000 (12:41 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 6 Jun 2007 10:41:12 +0000 (12:41 +0200)
2007-04-20  Arnaud Charlet  <charlet@adacore.com>

* restrict.ads, restrict.adb (No_Exception_Handlers_Set): Only return
true if configurable run-time or No_Run_Time is set.
(Set_Restriction): Avoid setting restriction No_Elaboration_Code when
processing an unit which is not the one being compiled.

From-SVN: r125443

gcc/ada/restrict.adb
gcc/ada/restrict.ads

index c13537da39f9e76dd94dfea78a98c0a4704ebe54..03905ec690b43895b2acaa77d335440485fc3c76 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2006, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2007, 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- --
@@ -30,7 +30,6 @@ with Errout;   use Errout;
 with Fname;    use Fname;
 with Fname.UF; use Fname.UF;
 with Lib;      use Lib;
-with Namet;    use Namet;
 with Opt;      use Opt;
 with Sinfo;    use Sinfo;
 with Sinput;   use Sinput;
@@ -416,7 +415,10 @@ package body Restrict is
 
    function No_Exception_Handlers_Set return Boolean is
    begin
-      return Restrictions.Set (No_Exception_Handlers);
+      return (No_Run_Time_Mode or else Configurable_Run_Time_Mode)
+        and then (Restrictions.Set (No_Exception_Handlers)
+                    or else
+                  Restrictions.Set (No_Exception_Propagation));
    end No_Exception_Handlers_Set;
 
    ----------------------------------
@@ -625,6 +627,23 @@ package body Restrict is
       N : Node_Id)
    is
    begin
+      --  Restriction No_Elaboration_Code must be enforced on a unit by unit
+      --  basis. Hence, we avoid setting the restriction when processing an
+      --  unit which is not the main one being compiled (or its corresponding
+      --  spec). It can happen, for example, when processing an inlined body
+      --  (the package containing the inlined subprogram is analyzed,
+      --  including its pragma Restrictions).
+
+      --  This seems like a very nasty kludge??? This is not the only per unit
+      --  restriction why is this treated specially ???
+
+      if R = No_Elaboration_Code
+        and then Current_Sem_Unit /= Main_Unit
+        and then Cunit (Current_Sem_Unit) /= Library_Unit (Cunit (Main_Unit))
+      then
+         return;
+      end if;
+
       Restrictions.Set (R) := True;
 
       if Restricted_Profile_Cached and Restricted_Profile_Result then
index 063de24955e8b9fb2400e96779f7bca5d533b83f..e453ed85779e91d38b6b627f721ba1573ad5bf7f 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2006, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2007, 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- --
@@ -26,6 +26,7 @@
 
 --  This package deals with the implementation of the Restrictions pragma
 
+with Namet;  use Namet;
 with Rident; use Rident;
 with Table;
 with Types;  use Types;
@@ -231,7 +232,11 @@ package Restrict is
    function No_Exception_Handlers_Set return Boolean;
    --  Test to see if current restrictions settings specify that no exception
    --  handlers are present. This function is called by Gigi when it needs to
-   --  expand an AT END clean up identifier with no exception handler.
+   --  expand an AT END clean up identifier with no exception handler. True
+   --  will be returned if the configurable run-time is activated, and either
+   --  of the restrictions No_Exception_Handlers or No_Exception_Propagation is
+   --  set. In the latter case, the source may contain handlers but they either
+   --  get converted using the local goto transformation or deleted.
 
    function Process_Restriction_Synonyms (N : Node_Id) return Name_Id;
    --  Id is a node whose Chars field contains the name of a restriction.