OSDN Git Service

PR preprocessor/30805:
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-purexc.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT RUN-TIME COMPONENTS                         --
4 --                                                                          --
5 --               S Y S T E M . P U R E _ E X C E P T I O N S                --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 2000-2007, Free Software Foundation, Inc.         --
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 2,  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.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- As a special exception,  if other files  instantiate  generics from this --
23 -- unit, or you link  this unit with other files  to produce an executable, --
24 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
25 -- covered  by the  GNU  General  Public  License.  This exception does not --
26 -- however invalidate  any other reasons why  the executable file  might be --
27 -- covered by the  GNU Public License.                                      --
28 --                                                                          --
29 -- GNAT was originally developed  by the GNAT team at  New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
31 --                                                                          --
32 ------------------------------------------------------------------------------
33
34 --  This package provides an interface for raising predefined exceptions with
35 --  an exception message. It can be used from Pure units. This unit is for
36 --  internal use only, it is not generally available to applications.
37
38 pragma Warnings (Off);
39 pragma Compiler_Unit;
40 pragma Warnings (On);
41
42 package System.Pure_Exceptions is
43    pragma Pure;
44
45    type Exception_Type is limited null record;
46    --  Type used to specify which exception to raise
47
48    --  Really Exception_Type is Exception_Id, but Exception_Id can't be
49    --  used directly since it is declared in the non-pure unit Ada.Exceptions,
50
51    --  Exception_Id is in fact simply a pointer to the type Exception_Data
52    --  declared in System.Standard_Library (which is also non-pure). So what
53    --  we do is to define it here as a by reference type (any by reference
54    --  type would do), and then Import the definitions from Standard_Library.
55    --  Since this is a by reference type, these will be passed by reference,
56    --  which has the same effect as passing a pointer.
57
58    --  This type is not private because keeping it by reference would require
59    --  defining it in a way (e.g a tagged type) that would drag other run time
60    --  files, which is unwanted in the case of e.g ravenscar where we want to
61    --  minimize the number of run time files needed by default.
62
63    CE : constant Exception_Type;  -- Constraint_Error
64    PE : constant Exception_Type;  -- Program_Error
65    SE : constant Exception_Type;  -- Storage_Error
66    TE : constant Exception_Type;  -- Tasking_Error
67    --  One of these constants is used in the call to specify the exception
68
69    procedure Raise_Exception (E : Exception_Type; Message : String);
70    pragma Import (Ada, Raise_Exception, "__gnat_raise_exception");
71    pragma No_Return (Raise_Exception);
72    --  Raise specified exception with specified message
73
74 private
75    pragma Import (C, CE, "constraint_error");
76    pragma Import (C, PE, "program_error");
77    pragma Import (C, SE, "storage_error");
78    pragma Import (C, TE, "tasking_error");
79    --  References to the exception structures in the standard library
80
81 end System.Pure_Exceptions;