aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/restrict.adb
diff options
context:
space:
mode:
authorRobert Dewar <dewar@adacore.com>2011-11-21 11:45:44 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2011-11-21 12:45:44 +0100
commit51fb9b7396ee1201ea65164507f53c66a5a7d770 (patch)
treefb9bebfb673ba0712a1a7bf85196eb0f3f51c752 /gcc/ada/restrict.adb
parent56272abec68769b5638003ec3227a8097a60b321 (diff)
downloadgcc-51fb9b7396ee1201ea65164507f53c66a5a7d770.zip
gcc-51fb9b7396ee1201ea65164507f53c66a5a7d770.tar.gz
gcc-51fb9b7396ee1201ea65164507f53c66a5a7d770.tar.bz2
frontend.adb (Frontend): Capture restrictions from config files
2011-11-21 Robert Dewar <dewar@adacore.com> * frontend.adb (Frontend): Capture restrictions from config files * lib-load.adb (Load_Unit): Save/set/restore restriction pragma information * lib-xref.adb (Generate_Reference): Fix handling of obsolescent references. This was noticed during debugging, but it is not known if it causes real bugs. * restrict.ads, restrict.adb: New routines to save/set/restore non-partition-wide restrictions. * s-rident.ads: Comment changes for new handling of No_Elaboration_Code * sem.adb (Sem): Save/Set/Restore non-partition-wide restrictions * sem_ch10.adb (Analyze_Compilation_Unit): Remove incomplete attempt to save/restore non-partition-wide restrictions (now this work is all done in Sem). * sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings): Special handling for restriction No_Elaboration_Code. 2011-11-21 Robert Dewar <dewar@adacore.com> * gnat_ugn.texi: Document new handling of restrictions pragmas. From-SVN: r181566
Diffstat (limited to 'gcc/ada/restrict.adb')
-rw-r--r--gcc/ada/restrict.adb75
1 files changed, 56 insertions, 19 deletions
diff --git a/gcc/ada/restrict.adb b/gcc/ada/restrict.adb
index 399547c..df2ec7a 100644
--- a/gcc/ada/restrict.adb
+++ b/gcc/ada/restrict.adb
@@ -41,6 +41,9 @@ with Uname; use Uname;
package body Restrict is
+ Config_Cunit_Boolean_Restrictions : Save_Cunit_Boolean_Restrictions;
+ -- Save compilation unit restrictions set by config pragma files
+
Restricted_Profile_Result : Boolean := False;
-- This switch memoizes the result of Restricted_Profile function calls for
-- improved efficiency. Valid only if Restricted_Profile_Cached is True.
@@ -100,6 +103,17 @@ package body Restrict is
end if;
end Abort_Allowed;
+ ----------------------------------------
+ -- Add_To_Config_Boolean_Restrictions --
+ ----------------------------------------
+
+ procedure Add_To_Config_Boolean_Restrictions (R : Restriction_Id) is
+ begin
+ Config_Cunit_Boolean_Restrictions (R) := True;
+ end Add_To_Config_Boolean_Restrictions;
+ -- Add specified restriction to stored configuration boolean restrictions.
+ -- This is used for handling the special case of No_Elaboration_Code.
+
-------------------------
-- Check_Compiler_Unit --
-------------------------
@@ -498,7 +512,9 @@ package body Restrict is
Update_Restrictions (Restrictions);
- -- If in main extended unit, update main restrictions as well
+ -- If in main extended unit, update main restrictions as well. Note
+ -- that as usual we check for Main_Unit explicitly to deal with the
+ -- case of configuration pragma files.
if Current_Sem_Unit = Main_Unit
or else In_Extended_Main_Source_Unit (N)
@@ -642,6 +658,16 @@ package body Restrict is
for J in Cunit_Boolean_Restrictions loop
Restrictions.Set (J) := R (J);
end loop;
+
+ -- If No_Elaboration_Code set in configuration restrictions, and we
+ -- in the main extended source, then set it here now. This is part of
+ -- the special processing for No_Elaboration_Code.
+
+ if In_Extended_Main_Source_Unit (Cunit_Entity (Current_Sem_Unit))
+ and then Config_Cunit_Boolean_Restrictions (No_Elaboration_Code)
+ then
+ Restrictions.Set (No_Elaboration_Code) := True;
+ end if;
end Cunit_Boolean_Restrictions_Restore;
-------------------------------------
@@ -656,7 +682,6 @@ package body Restrict is
begin
for J in Cunit_Boolean_Restrictions loop
R (J) := Restrictions.Set (J);
- Restrictions.Set (J) := False;
end loop;
return R;
@@ -772,6 +797,26 @@ package body Restrict is
return New_Name;
end Process_Restriction_Synonyms;
+ --------------------------------------
+ -- Reset_Cunit_Boolean_Restrictions --
+ --------------------------------------
+
+ procedure Reset_Cunit_Boolean_Restrictions is
+ begin
+ for J in Cunit_Boolean_Restrictions loop
+ Restrictions.Set (J) := False;
+ end loop;
+ end Reset_Cunit_Boolean_Restrictions;
+
+ -----------------------------------------------
+ -- Restore_Config_Cunit_Boolean_Restrictions --
+ -----------------------------------------------
+
+ procedure Restore_Config_Cunit_Boolean_Restrictions is
+ begin
+ Cunit_Boolean_Restrictions_Restore (Config_Cunit_Boolean_Restrictions);
+ end Restore_Config_Cunit_Boolean_Restrictions;
+
------------------------
-- Restricted_Profile --
------------------------
@@ -1004,6 +1049,15 @@ package body Restrict is
end if;
end Same_Unit;
+ --------------------------------------------
+ -- Save_Config_Cunit_Boolean_Restrictions --
+ --------------------------------------------
+
+ procedure Save_Config_Cunit_Boolean_Restrictions is
+ begin
+ Config_Cunit_Boolean_Restrictions := Cunit_Boolean_Restrictions_Save;
+ end Save_Config_Cunit_Boolean_Restrictions;
+
------------------------------
-- Set_Hidden_Part_In_SPARK --
------------------------------
@@ -1070,23 +1124,6 @@ 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