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] fix handling of pragma Suppress_Exception_Locations


Tested on i686-linux, committed on mainline.

When using pragma Suppress_Exception_Locations with the Zero FootPrint run
time, the source location was always passed to the last chance handler,
regardless of the aforementioned pragma.
There is a flag in gigi for avoiding the generation of these file names,
which is set when the -gnatdN switch is passed to the compiler. The fix
consists on setting this flag also when pragma Supress_Exception_Locations
has been detected by the front-end.

Test case checks that file names are not passed to the last chance handler
when pragma Supress_Exception_Locations is in effect.
The expected output when executing them is:
File name supressed
--
pragma restrictions (No_Exception_Handlers);
pragma Suppress_Exception_Locations;
with Last_Chance_Handler;

procedure main is
begin
   raise Program_Error;
end main;
with System;

procedure Last_Chance_Handler (Msg : System.Address; Line : Integer);
pragma Export (C, Last_Chance_Handler, "__gnat_last_chance_handler");
pragma No_Return (Last_Chance_Handler);
with Ada.Text_IO;

procedure Last_Chance_Handler (Msg : System.Address; Line : Integer) is

   Data : Character;
   for Data'Address use Msg;

   procedure C_Exit (Status : Integer);
   pragma Import (C, C_Exit, "exit");
   pragma No_Return (C_Exit);

begin

   if Data = ASCII.NUL then
      Ada.Text_IO.Put_Line ("File name supressed");
   else
      Ada.Text_IO.Put_Line ("File name not suppressed");
   end if;

   --  We cannot return from the last chance handler, so that we finish
   --  execution here.

   C_Exit (0);
end Last_Chance_Handler;
--
gnatmake -gnatp main.adb
main

2005-06-14  Jose Ruiz  <ruiz@adacore.com>

	* fe.h: Add entry for Opt.Exception_Locations_Suppressed so that gigi
	can determine whether pragma Suppress_Exception_Locations is in effect.

	* utils2.c (build_call_raise): Do not pass the file name to the
	exception handler if pragma Suppress_Exception_Locations is in effect.
	(build_allocator): Add and process arg IGNORE_INIT_TYPE.

Attachment: difs.26
Description: Text document


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