Commit 4dcfaf77 by Robert Dewar Committed by Arnaud Charlet

gnatbind.adb (Restriction_Could_Be_Set): New procedure

2008-04-08  Robert Dewar  <dewar@adacore.com>

	* gnatbind.adb (Restriction_Could_Be_Set): New procedure
	(List_Applicable_Restrictions): Do not list existing restrictions

From-SVN: r134035
parent 8f3366c6
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2007, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2008, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -164,19 +164,68 @@ procedure Gnatbind is ...@@ -164,19 +164,68 @@ procedure Gnatbind is
Additional_Restrictions_Listed : Boolean := False; Additional_Restrictions_Listed : Boolean := False;
-- Set True if we have listed header for restrictions -- Set True if we have listed header for restrictions
function Restriction_Could_Be_Set (R : Restriction_Id) return Boolean;
-- Returns True if the given restriction can be listed as an additional
-- restriction that could be set.
------------------------------
-- Restriction_Could_Be_Set --
------------------------------
function Restriction_Could_Be_Set (R : Restriction_Id) return Boolean is
CR : Restrictions_Info renames Cumulative_Restrictions;
begin begin
-- Loop through restrictions case R is
for R in All_Restrictions loop -- Boolean restriction
if not No_Restriction_List (R) then
-- We list a restriction if it is not violated, or if when All_Boolean_Restrictions =>
-- it is violated but the violation count is exactly known.
if Cumulative_Restrictions.Violated (R) = False -- The condition for listing a boolean restriction as an
or else (R in All_Parameter_Restrictions -- additional restriction that could be set is that it is
and then -- not violated by any unit, and not already set.
Cumulative_Restrictions.Unknown (R) = False)
return CR.Violated (R) = False and then CR.Set (R) = False;
-- Parameter restriction
when All_Parameter_Restrictions =>
-- If the restriction is violated and the level of violation is
-- unknown, the restriction can definitely not be listed.
if CR.Violated (R) and then CR.Unknown (R) then
return False;
-- We can list the restriction if it is not set
elsif not CR.Set (R) then
return True;
-- We can list the restriction if is set to a greater value
-- than the maximum value known for the violation.
else
return CR.Value (R) > CR.Count (R);
end if;
-- No other values for R possible
when others =>
raise Program_Error;
end case;
end Restriction_Could_Be_Set;
-- Start of processing for List_Applicable_Restrictions
begin
-- Loop through restrictions
for R in All_Restrictions loop
if not No_Restriction_List (R)
and then Restriction_Could_Be_Set (R)
then then
if not Additional_Restrictions_Listed then if not Additional_Restrictions_Listed then
Write_Eol; Write_Eol;
...@@ -206,7 +255,6 @@ procedure Gnatbind is ...@@ -206,7 +255,6 @@ procedure Gnatbind is
Write_Str (");"); Write_Str (");");
Write_Eol; Write_Eol;
end if; end if;
end if;
end loop; end loop;
end List_Applicable_Restrictions; end List_Applicable_Restrictions;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment