This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Modify Assertion_Policy pragma


Tested on i686-linux, committed on HEAD

This update modifies pragma Assertion_Policy so that it affects only
pragma Assert and not pragma Debug, which seems closer to the intent
of the new Ada 2005 pragma. It also introduces a new analogous pragma
Debug_Policy to control activation of pragma Debug,

The following set of five programs tests this feature:

with text_io; use text_io;
procedure p is
   function atest return boolean is
   begin
      put_line ("assert active");
      return true;
   end;
begin
  put_line ("start");
  pragma debug (put_line ("debug active"));
  pragma assert (atest);
  put_line ("end");
end;

pragma assertion_policy (ignore);
with text_io; use text_io;
procedure paoff is
   function atest return boolean is
   begin
      put_line ("assert active");
      return true;
   end;
begin
  put_line ("start");
  pragma debug (put_line ("debug active"));
  pragma assert (atest);
  put_line ("end");
end;

pragma assertion_policy (check);
with text_io; use text_io;
procedure paon is
   function atest return boolean is
   begin
      put_line ("assert active");
      return true;
   end;
begin
  put_line ("start");
  pragma debug (put_line ("debug active"));
  pragma assert (atest);
  put_line ("end");
end;

pragma debug_policy (ignore);
with text_io; use text_io;
procedure pdoff is
   function atest return boolean is
   begin
      put_line ("assert active");
      return true;
   end;
begin
  put_line ("start");
  pragma debug (put_line ("debug active"));
  pragma assert (atest);
  put_line ("end");
end;

pragma debug_policy (check);
with text_io; use text_io;
procedure pdon is
   function atest return boolean is
   begin
      put_line ("assert active");
      return true;
   end;
begin
  put_line ("start");
  pragma debug (put_line ("debug active"));
  pragma assert (atest);
  put_line ("end");
end;

with the test script:

gnatmake -f -q  p.adb
p
gnatmake -f -q  p.adb -gnata
p
gnatmake -f -q  paon.adb
paon
gnatmake -f -q  paon.adb -gnata
paon
gnatmake -f -q  paoff.adb
paoff
gnatmake -f -q  paoff.adb -gnata
paoff
gnatmake -f -q  pdon.adb
pdon
gnatmake -f -q  pdon.adb -gnata
pdon
gnatmake -f -q  pdoff.adb
pdoff
gnatmake -f -q  pdoff.adb -gnata
pdoff

should generate the following output:

start
end
start
debug active
assert active
end
start
assert active
end
start
debug active
assert active
end
start
end
start
debug active
end
start
debug active
end
start
debug active
assert active
end
start
end
start
assert active
end

Also modify -gnatg mode to set Ada 2005 mode explicitely.
We don't want to rely on the implicit setting here, since for example,
we want Preelaborate_05 treated as Preelaborate.

2005-09-01  Robert Dewar  <dewar@adacore.com>

	* opt.ads, opt.adb: Add new switches Debug_Pragmas_Enabled[_Config]

	* par-prag.adb: Implement new pragma Debug_Policy

	* sem_prag.adb Implement new pragma Debug_Policy
	(Analyze_Pragma, case Pack): do not let pragma Pack override an explicit
	Component_Size attribute specification. Give warning for ignored pragma
	Pack.

	* snames.h, snames.ads, snames.adb: Introduce entries in
	Preset_Names for Name_Disp_Asynchronous_Select,
	Name_Disp_Conditional_Select, Name_Disp_Get_Prim_Op_Kind,
	Name_Disp_Timed_Select.
	New pragma Debug_Policy

	* switch-c.adb (Scan_Front_End_Switches): Set Ada 2005 mode
	explicitly.
	Switch -gnata also sets Debug_Pragmas_Enabled

	* sem.adb, par.adb (Set_Opt_Config_Switch): Add parameter Main_Unit to
	handle an explicit -gnata when compiling predefined files.

Attachment: difs.27
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]