gcc/ada/
[official-gcc.git] / gcc / ada / g-moreex.adb
blob822b760711ed050751685d8bfa25d79de882c1d7
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT LIBRARY COMPONENTS --
4 -- --
5 -- G N A T . M O S T _ R E C E N T _ E X C E P T I O N --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2000-2010, AdaCore --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
17 -- --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
21 -- --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
26 -- --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
29 -- --
30 ------------------------------------------------------------------------------
32 with Ada.Exceptions.Is_Null_Occurrence;
33 with System.Soft_Links;
35 package body GNAT.Most_Recent_Exception is
37 ----------------
38 -- Occurrence --
39 ----------------
41 function Occurrence return Ada.Exceptions.Exception_Occurrence is
42 EOA : constant Ada.Exceptions.Exception_Occurrence_Access :=
43 GNAT.Most_Recent_Exception.Occurrence_Access;
45 use type Ada.Exceptions.Exception_Occurrence_Access;
47 begin
48 return Result : Ada.Exceptions.Exception_Occurrence do
49 if EOA = null then
50 Ada.Exceptions.Save_Occurrence
51 (Target => Result,
52 Source => Ada.Exceptions.Null_Occurrence);
53 else
54 Ada.Exceptions.Save_Occurrence
55 (Target => Result,
56 Source => EOA.all);
57 end if;
58 end return;
59 end Occurrence;
61 -----------------------
62 -- Occurrence_Access --
63 -----------------------
65 function Occurrence_Access
66 return Ada.Exceptions.Exception_Occurrence_Access
68 use Ada.Exceptions;
70 EOA : constant Exception_Occurrence_Access :=
71 System.Soft_Links.Get_Current_Excep.all;
73 begin
74 if EOA = null then
75 return null;
77 elsif Is_Null_Occurrence (EOA.all) then
78 return null;
80 else
81 return EOA;
82 end if;
83 end Occurrence_Access;
85 end GNAT.Most_Recent_Exception;