OSDN Git Service

Fix PR c++/42260 and ensure PR c++/45383 is fixed
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-except.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                       A D A . E X C E P T I O N S                        --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2010, 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 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 ------------------------------------------------------------------------------
31
32 --  This version of Ada.Exceptions is a full Ada 95 version, and Ada 2005
33 --  features such as the additional definitions of Exception_Name returning
34 --  Wide_[Wide_]String.
35
36 --  It is used for building the compiler and the basic tools, since these
37 --  builds may be done with bootstrap compilers that cannot handle these
38 --  additions. The full version of Ada.Exceptions can be found in the files
39 --  a-except-2005.ads/adb, and is used for all other builds where full Ada
40 --  2005 functionality is required. In particular, it is used for building
41 --  run times on all targets.
42
43 pragma Compiler_Unit;
44
45 pragma Style_Checks (All_Checks);
46 --  No subprogram ordering check, due to logical grouping
47
48 pragma Polling (Off);
49 --  We must turn polling off for this unit, because otherwise we get
50 --  elaboration circularities with System.Exception_Tables.
51
52 with System;                  use System;
53 with System.Exceptions;       use System.Exceptions;
54 with System.Standard_Library; use System.Standard_Library;
55 with System.Soft_Links;       use System.Soft_Links;
56
57 package body Ada.Exceptions is
58
59    pragma Suppress (All_Checks);
60    --  We definitely do not want exceptions occurring within this unit, or we
61    --  are in big trouble. If an exceptional situation does occur, better that
62    --  it not be raised, since raising it can cause confusing chaos.
63
64    -----------------------
65    -- Local Subprograms --
66    -----------------------
67
68    --  Note: the exported subprograms in this package body are called directly
69    --  from C clients using the given external name, even though they are not
70    --  technically visible in the Ada sense.
71
72    procedure Process_Raise_Exception (E : Exception_Id);
73    pragma No_Return (Process_Raise_Exception);
74    --  This is the lowest level raise routine. It raises the exception
75    --  referenced by Current_Excep.all in the TSD, without deferring abort
76    --  (the caller must ensure that abort is deferred on entry).
77
78    procedure To_Stderr (S : String);
79    pragma Export (Ada, To_Stderr, "__gnat_to_stderr");
80    --  Little routine to output string to stderr that is also used in the
81    --  tasking run time.
82
83    procedure To_Stderr (C : Character);
84    pragma Inline (To_Stderr);
85    pragma Export (Ada, To_Stderr, "__gnat_to_stderr_char");
86    --  Little routine to output a character to stderr, used by some of the
87    --  separate units below.
88
89    package Exception_Data is
90
91       ---------------------------------
92       -- Exception messages routines --
93       ---------------------------------
94
95       procedure Set_Exception_C_Msg
96         (Id     : Exception_Id;
97          Msg1   : System.Address;
98          Line   : Integer        := 0;
99          Column : Integer        := 0;
100          Msg2   : System.Address := System.Null_Address);
101       --  This routine is called to setup the exception referenced by the
102       --  Current_Excep field in the TSD to contain the indicated Id value
103       --  and message. Msg1 is a null terminated string which is generated
104       --  as the exception message. If line is non-zero, then a colon and
105       --  the decimal representation of this integer is appended to the
106       --  message. Ditto for Column. When Msg2 is non-null, a space and this
107       --  additional null terminated string is added to the message.
108
109       procedure Set_Exception_Msg
110         (Id      : Exception_Id;
111          Message : String);
112       --  This routine is called to setup the exception referenced by the
113       --  Current_Excep field in the TSD to contain the indicated Id value and
114       --  message. Message is a string which is generated as the exception
115       --  message.
116
117       --------------------------------------
118       -- Exception information subprogram --
119       --------------------------------------
120
121       function Exception_Information (X : Exception_Occurrence) return String;
122       --  The format of the exception information is as follows:
123       --
124       --    Exception_Name: <exception name> (as in Exception_Name)
125       --    Message: <message> (only if Exception_Message is empty)
126       --    PID=nnnn (only if != 0)
127       --    Call stack traceback locations:  (only if at least one location)
128       --    <0xyyyyyyyy 0xyyyyyyyy ...>      (is recorded)
129       --
130       --  The lines are separated by a ASCII.LF character
131       --
132       --  The nnnn is the partition Id given as decimal digits
133       --
134       --  The 0x... line represents traceback program counter locations, in
135       --  execution order with the first one being the exception location. It
136       --  is present only
137       --
138       --  The Exception_Name and Message lines are omitted in the abort signal
139       --  case, since this is not really an exception.
140
141       --  Note: If the format of the generated string is changed, please note
142       --  that an equivalent modification to the routine String_To_EO must be
143       --  made to preserve proper functioning of the stream attributes.
144
145       ---------------------------------------
146       -- Exception backtracing subprograms --
147       ---------------------------------------
148
149       --  What is automatically output when exception tracing is on is the
150       --  usual exception information with the call chain backtrace possibly
151       --  tailored by a backtrace decorator. Modifying Exception_Information
152       --  itself is not a good idea because the decorated output is completely
153       --  out of control and would break all our code related to the streaming
154       --  of exceptions.  We then provide an alternative function to compute
155       --  the possibly tailored output, which is equivalent if no decorator is
156       --  currently set:
157
158       function Tailored_Exception_Information
159         (X : Exception_Occurrence) return String;
160       --  Exception information to be output in the case of automatic tracing
161       --  requested through GNAT.Exception_Traces.
162       --
163       --  This is the same as Exception_Information if no backtrace decorator
164       --  is currently in place. Otherwise, this is Exception_Information with
165       --  the call chain raw addresses replaced by the result of a call to the
166       --  current decorator provided with the call chain addresses.
167
168       pragma Export
169         (Ada, Tailored_Exception_Information,
170            "__gnat_tailored_exception_information");
171       --  This is currently used by System.Tasking.Stages
172
173    end Exception_Data;
174
175    package Exception_Traces is
176
177       use Exception_Data;
178       --  Imports Tailored_Exception_Information
179
180       ----------------------------------------------
181       -- Run-Time Exception Notification Routines --
182       ----------------------------------------------
183
184       --  These subprograms provide a common run-time interface to trigger the
185       --  actions required when an exception is about to be propagated (e.g.
186       --  user specified actions or output of exception information). They are
187       --  exported to be usable by the Ada exception handling personality
188       --  routine when the GCC 3 mechanism is used.
189
190       procedure Notify_Handled_Exception;
191       pragma Export
192         (C, Notify_Handled_Exception, "__gnat_notify_handled_exception");
193       --  This routine is called for a handled occurrence is about to be
194       --  propagated.
195
196       procedure Notify_Unhandled_Exception;
197       pragma Export
198         (C, Notify_Unhandled_Exception, "__gnat_notify_unhandled_exception");
199       --  This routine is called when an unhandled occurrence is about to be
200       --  propagated.
201
202       procedure Unhandled_Exception_Terminate;
203       pragma No_Return (Unhandled_Exception_Terminate);
204       --  This procedure is called to terminate program execution following an
205       --  unhandled exception. The exception information, including traceback
206       --  if available is output, and execution is then terminated. Note that
207       --  at the point where this routine is called, the stack has typically
208       --  been destroyed.
209
210    end Exception_Traces;
211
212    package Exception_Propagation is
213
214       procedure Setup_Exception
215         (Excep    : EOA;
216          Current  : EOA;
217          Reraised : Boolean := False);
218       --  Dummy routine used to share a-exexda.adb, do nothing
219
220    end Exception_Propagation;
221
222    package Stream_Attributes is
223
224       --------------------------------
225       -- Stream attributes routines --
226       --------------------------------
227
228       function EId_To_String (X : Exception_Id) return String;
229       function String_To_EId (S : String) return Exception_Id;
230       --  Functions for implementing Exception_Id stream attributes
231
232       function EO_To_String (X : Exception_Occurrence) return String;
233       function String_To_EO (S : String) return Exception_Occurrence;
234       --  Functions for implementing Exception_Occurrence stream
235       --  attributes
236
237    end Stream_Attributes;
238
239    procedure Raise_Current_Excep (E : Exception_Id);
240    pragma No_Return (Raise_Current_Excep);
241    pragma Export (C, Raise_Current_Excep, "__gnat_raise_nodefer_with_msg");
242    --  This is a simple wrapper to Process_Raise_Exception.
243    --
244    --  This external name for Raise_Current_Excep is historical, and probably
245    --  should be changed but for now we keep it, because gdb and gigi know
246    --  about it.
247
248    procedure Raise_Exception_No_Defer
249       (E : Exception_Id; Message : String := "");
250    pragma Export
251     (Ada, Raise_Exception_No_Defer,
252      "ada__exceptions__raise_exception_no_defer");
253    pragma No_Return (Raise_Exception_No_Defer);
254    --  Similar to Raise_Exception, but with no abort deferral
255
256    procedure Raise_With_Msg (E : Exception_Id);
257    pragma No_Return (Raise_With_Msg);
258    pragma Export (C, Raise_With_Msg, "__gnat_raise_with_msg");
259    --  Raises an exception with given exception id value. A message is
260    --  associated with the raise, and has already been stored in the exception
261    --  occurrence referenced by the Current_Excep in the TSD. Abort is deferred
262    --  before the raise call.
263
264    procedure Raise_With_Location_And_Msg
265      (E : Exception_Id;
266       F : System.Address;
267       L : Integer;
268       M : System.Address := System.Null_Address);
269    pragma No_Return (Raise_With_Location_And_Msg);
270    --  Raise an exception with given exception id value. A filename and line
271    --  number is associated with the raise and is stored in the exception
272    --  occurrence and in addition a string message M is appended to this
273    --  if M is not null.
274
275    procedure Raise_Constraint_Error
276      (File : System.Address;
277       Line : Integer);
278    pragma No_Return (Raise_Constraint_Error);
279    pragma Export
280      (C, Raise_Constraint_Error, "__gnat_raise_constraint_error");
281    --  Raise constraint error with file:line information
282
283    procedure Raise_Constraint_Error_Msg
284      (File : System.Address;
285       Line : Integer;
286       Msg  : System.Address);
287    pragma No_Return (Raise_Constraint_Error_Msg);
288    pragma Export
289      (C, Raise_Constraint_Error_Msg, "__gnat_raise_constraint_error_msg");
290    --  Raise constraint error with file:line + msg information
291
292    procedure Raise_Program_Error
293      (File : System.Address;
294       Line : Integer);
295    pragma No_Return (Raise_Program_Error);
296    pragma Export
297      (C, Raise_Program_Error, "__gnat_raise_program_error");
298    --  Raise program error with file:line information
299
300    procedure Raise_Program_Error_Msg
301      (File : System.Address;
302       Line : Integer;
303       Msg  : System.Address);
304    pragma No_Return (Raise_Program_Error_Msg);
305    pragma Export
306      (C, Raise_Program_Error_Msg, "__gnat_raise_program_error_msg");
307    --  Raise program error with file:line + msg information
308
309    procedure Raise_Storage_Error
310      (File : System.Address;
311       Line : Integer);
312    pragma No_Return (Raise_Storage_Error);
313    pragma Export
314      (C, Raise_Storage_Error, "__gnat_raise_storage_error");
315    --  Raise storage error with file:line information
316
317    procedure Raise_Storage_Error_Msg
318      (File : System.Address;
319       Line : Integer;
320       Msg  : System.Address);
321    pragma No_Return (Raise_Storage_Error_Msg);
322    pragma Export
323      (C, Raise_Storage_Error_Msg, "__gnat_raise_storage_error_msg");
324    --  Raise storage error with file:line + reason msg information
325
326    --  The exception raising process and the automatic tracing mechanism rely
327    --  on some careful use of flags attached to the exception occurrence. The
328    --  graph below illustrates the relations between the Raise_ subprograms
329    --  and identifies the points where basic flags such as Exception_Raised
330    --  are initialized.
331    --
332    --  (i) signs indicate the flags initialization points. R stands for Raise,
333    --  W for With, and E for Exception.
334    --
335    --                   R_No_Msg    R_E   R_Pe  R_Ce  R_Se
336    --                       |        |     |     |     |
337    --                       +--+  +--+     +---+ | +---+
338    --                          |  |            | | |
339    --     R_E_No_Defer(i)    R_W_Msg(i)       R_W_Loc
340    --           |               |              |   |
341    --           +------------+  |  +-----------+   +--+
342    --                        |  |  |                  |
343    --                        |  |  |             Set_E_C_Msg(i)
344    --                        |  |  |
345    --                   Raise_Current_Excep
346
347    procedure Reraise;
348    pragma No_Return (Reraise);
349    pragma Export (C, Reraise, "__gnat_reraise");
350    --  Reraises the exception referenced by the Current_Excep field of the TSD
351    --  (all fields of this exception occurrence are set). Abort is deferred
352    --  before the reraise operation.
353
354    --  Save_Occurrence variations: As the management of the private data
355    --  attached to occurrences is delicate, whether or not pointers to such
356    --  data has to be copied in various situations is better made explicit.
357    --  The following procedures provide an internal interface to help making
358    --  this explicit.
359
360    procedure Save_Occurrence_No_Private
361      (Target : out Exception_Occurrence;
362       Source : Exception_Occurrence);
363    --  Copy all the components of Source to Target, except the
364    --  Private_Data pointer.
365
366    procedure Transfer_Occurrence
367      (Target : Exception_Occurrence_Access;
368       Source : Exception_Occurrence);
369    pragma Export (C, Transfer_Occurrence, "__gnat_transfer_occurrence");
370    --  Called from System.Tasking.RendezVous.Exceptional_Complete_RendezVous
371    --  to setup Target from Source as an exception to be propagated in the
372    --  caller task. Target is expected to be a pointer to the fixed TSD
373    --  occurrence for this task.
374
375    -----------------------------
376    -- Run-Time Check Routines --
377    -----------------------------
378
379    --  Routines to a specific exception with a reason message attached. The
380    --  parameters are the file name and line number in each case. The names are
381    --  keyed to the codes defined in types.ads and a-types.h (for example, the
382    --  name Rcheck_05 refers to the Reason RT_Exception_Code'Val (5)).
383
384    procedure Rcheck_00 (File : System.Address; Line : Integer);
385    procedure Rcheck_01 (File : System.Address; Line : Integer);
386    procedure Rcheck_02 (File : System.Address; Line : Integer);
387    procedure Rcheck_03 (File : System.Address; Line : Integer);
388    procedure Rcheck_04 (File : System.Address; Line : Integer);
389    procedure Rcheck_05 (File : System.Address; Line : Integer);
390    procedure Rcheck_06 (File : System.Address; Line : Integer);
391    procedure Rcheck_07 (File : System.Address; Line : Integer);
392    procedure Rcheck_08 (File : System.Address; Line : Integer);
393    procedure Rcheck_09 (File : System.Address; Line : Integer);
394    procedure Rcheck_10 (File : System.Address; Line : Integer);
395    procedure Rcheck_11 (File : System.Address; Line : Integer);
396    procedure Rcheck_12 (File : System.Address; Line : Integer);
397    procedure Rcheck_13 (File : System.Address; Line : Integer);
398    procedure Rcheck_14 (File : System.Address; Line : Integer);
399    procedure Rcheck_15 (File : System.Address; Line : Integer);
400    procedure Rcheck_16 (File : System.Address; Line : Integer);
401    procedure Rcheck_17 (File : System.Address; Line : Integer);
402    procedure Rcheck_18 (File : System.Address; Line : Integer);
403    procedure Rcheck_19 (File : System.Address; Line : Integer);
404    procedure Rcheck_20 (File : System.Address; Line : Integer);
405    procedure Rcheck_21 (File : System.Address; Line : Integer);
406    procedure Rcheck_22 (File : System.Address; Line : Integer);
407    procedure Rcheck_23 (File : System.Address; Line : Integer);
408    procedure Rcheck_24 (File : System.Address; Line : Integer);
409    procedure Rcheck_25 (File : System.Address; Line : Integer);
410    procedure Rcheck_26 (File : System.Address; Line : Integer);
411    procedure Rcheck_27 (File : System.Address; Line : Integer);
412    procedure Rcheck_28 (File : System.Address; Line : Integer);
413    procedure Rcheck_29 (File : System.Address; Line : Integer);
414    procedure Rcheck_30 (File : System.Address; Line : Integer);
415    procedure Rcheck_31 (File : System.Address; Line : Integer);
416    procedure Rcheck_32 (File : System.Address; Line : Integer);
417    procedure Rcheck_33 (File : System.Address; Line : Integer);
418    procedure Rcheck_34 (File : System.Address; Line : Integer);
419
420    pragma Export (C, Rcheck_00, "__gnat_rcheck_00");
421    pragma Export (C, Rcheck_01, "__gnat_rcheck_01");
422    pragma Export (C, Rcheck_02, "__gnat_rcheck_02");
423    pragma Export (C, Rcheck_03, "__gnat_rcheck_03");
424    pragma Export (C, Rcheck_04, "__gnat_rcheck_04");
425    pragma Export (C, Rcheck_05, "__gnat_rcheck_05");
426    pragma Export (C, Rcheck_06, "__gnat_rcheck_06");
427    pragma Export (C, Rcheck_07, "__gnat_rcheck_07");
428    pragma Export (C, Rcheck_08, "__gnat_rcheck_08");
429    pragma Export (C, Rcheck_09, "__gnat_rcheck_09");
430    pragma Export (C, Rcheck_10, "__gnat_rcheck_10");
431    pragma Export (C, Rcheck_11, "__gnat_rcheck_11");
432    pragma Export (C, Rcheck_12, "__gnat_rcheck_12");
433    pragma Export (C, Rcheck_13, "__gnat_rcheck_13");
434    pragma Export (C, Rcheck_14, "__gnat_rcheck_14");
435    pragma Export (C, Rcheck_15, "__gnat_rcheck_15");
436    pragma Export (C, Rcheck_16, "__gnat_rcheck_16");
437    pragma Export (C, Rcheck_17, "__gnat_rcheck_17");
438    pragma Export (C, Rcheck_18, "__gnat_rcheck_18");
439    pragma Export (C, Rcheck_19, "__gnat_rcheck_19");
440    pragma Export (C, Rcheck_20, "__gnat_rcheck_20");
441    pragma Export (C, Rcheck_21, "__gnat_rcheck_21");
442    pragma Export (C, Rcheck_22, "__gnat_rcheck_22");
443    pragma Export (C, Rcheck_23, "__gnat_rcheck_23");
444    pragma Export (C, Rcheck_24, "__gnat_rcheck_24");
445    pragma Export (C, Rcheck_25, "__gnat_rcheck_25");
446    pragma Export (C, Rcheck_26, "__gnat_rcheck_26");
447    pragma Export (C, Rcheck_27, "__gnat_rcheck_27");
448    pragma Export (C, Rcheck_28, "__gnat_rcheck_28");
449    pragma Export (C, Rcheck_29, "__gnat_rcheck_29");
450    pragma Export (C, Rcheck_30, "__gnat_rcheck_30");
451    pragma Export (C, Rcheck_31, "__gnat_rcheck_31");
452    pragma Export (C, Rcheck_32, "__gnat_rcheck_32");
453    pragma Export (C, Rcheck_33, "__gnat_rcheck_33");
454    pragma Export (C, Rcheck_34, "__gnat_rcheck_34");
455
456    --  None of these procedures ever returns (they raise an exception!). By
457    --  using pragma No_Return, we ensure that any junk code after the call,
458    --  such as normal return epilog stuff, can be eliminated).
459
460    pragma No_Return (Rcheck_00);
461    pragma No_Return (Rcheck_01);
462    pragma No_Return (Rcheck_02);
463    pragma No_Return (Rcheck_03);
464    pragma No_Return (Rcheck_04);
465    pragma No_Return (Rcheck_05);
466    pragma No_Return (Rcheck_06);
467    pragma No_Return (Rcheck_07);
468    pragma No_Return (Rcheck_08);
469    pragma No_Return (Rcheck_09);
470    pragma No_Return (Rcheck_10);
471    pragma No_Return (Rcheck_11);
472    pragma No_Return (Rcheck_12);
473    pragma No_Return (Rcheck_13);
474    pragma No_Return (Rcheck_14);
475    pragma No_Return (Rcheck_15);
476    pragma No_Return (Rcheck_16);
477    pragma No_Return (Rcheck_17);
478    pragma No_Return (Rcheck_18);
479    pragma No_Return (Rcheck_19);
480    pragma No_Return (Rcheck_20);
481    pragma No_Return (Rcheck_21);
482    pragma No_Return (Rcheck_22);
483    pragma No_Return (Rcheck_23);
484    pragma No_Return (Rcheck_24);
485    pragma No_Return (Rcheck_25);
486    pragma No_Return (Rcheck_26);
487    pragma No_Return (Rcheck_27);
488    pragma No_Return (Rcheck_28);
489    pragma No_Return (Rcheck_29);
490    pragma No_Return (Rcheck_30);
491    pragma No_Return (Rcheck_32);
492    pragma No_Return (Rcheck_33);
493    pragma No_Return (Rcheck_34);
494
495    ---------------------------------------------
496    -- Reason Strings for Run-Time Check Calls --
497    ---------------------------------------------
498
499    --  These strings are null-terminated and are used by Rcheck_nn. The
500    --  strings correspond to the definitions for Types.RT_Exception_Code.
501
502    use ASCII;
503
504    Rmsg_00 : constant String := "access check failed"              & NUL;
505    Rmsg_01 : constant String := "access parameter is null"         & NUL;
506    Rmsg_02 : constant String := "discriminant check failed"        & NUL;
507    Rmsg_03 : constant String := "divide by zero"                   & NUL;
508    Rmsg_04 : constant String := "explicit raise"                   & NUL;
509    Rmsg_05 : constant String := "index check failed"               & NUL;
510    Rmsg_06 : constant String := "invalid data"                     & NUL;
511    Rmsg_07 : constant String := "length check failed"              & NUL;
512    Rmsg_08 : constant String := "null Exception_Id"                & NUL;
513    Rmsg_09 : constant String := "null-exclusion check failed"      & NUL;
514    Rmsg_10 : constant String := "overflow check failed"            & NUL;
515    Rmsg_11 : constant String := "partition check failed"           & NUL;
516    Rmsg_12 : constant String := "range check failed"               & NUL;
517    Rmsg_13 : constant String := "tag check failed"                 & NUL;
518    Rmsg_14 : constant String := "access before elaboration"        & NUL;
519    Rmsg_15 : constant String := "accessibility check failed"       & NUL;
520    Rmsg_16 : constant String := "attempt to take address of"       &
521                                 " intrinsic subprogram"            & NUL;
522    Rmsg_17 : constant String := "all guards closed"                & NUL;
523    Rmsg_18 : constant String := "improper use of generic subtype"  &
524                                 " with predicate"                  & NUL;
525    Rmsg_19 : constant String := "Current_Task referenced in entry" &
526                                 " body"                            & NUL;
527    Rmsg_20 : constant String := "duplicated entry address"         & NUL;
528    Rmsg_21 : constant String := "explicit raise"                   & NUL;
529    Rmsg_22 : constant String := "finalize/adjust raised exception" & NUL;
530    Rmsg_23 : constant String := "implicit return with No_Return"   & NUL;
531    Rmsg_24 : constant String := "misaligned address value"         & NUL;
532    Rmsg_25 : constant String := "missing return"                   & NUL;
533    Rmsg_26 : constant String := "overlaid controlled object"       & NUL;
534    Rmsg_27 : constant String := "potentially blocking operation"   & NUL;
535    Rmsg_28 : constant String := "stubbed subprogram called"        & NUL;
536    Rmsg_29 : constant String := "unchecked union restriction"      & NUL;
537    Rmsg_30 : constant String := "actual/returned class-wide"       &
538                                 " value not transportable"         & NUL;
539    Rmsg_31 : constant String := "empty storage pool"               & NUL;
540    Rmsg_32 : constant String := "explicit raise"                   & NUL;
541    Rmsg_33 : constant String := "infinite recursion"               & NUL;
542    Rmsg_34 : constant String := "object too large"                 & NUL;
543
544    -----------------------
545    -- Polling Interface --
546    -----------------------
547
548    type Unsigned is mod 2 ** 32;
549
550    Counter : Unsigned := 0;
551    pragma Warnings (Off, Counter);
552    --  This counter is provided for convenience. It can be used in Poll to
553    --  perform periodic but not systematic operations.
554
555    procedure Poll is separate;
556    --  The actual polling routine is separate, so that it can easily be
557    --  replaced with a target dependent version.
558
559    ------------------------------
560    -- Current_Target_Exception --
561    ------------------------------
562
563    function Current_Target_Exception return Exception_Occurrence is
564    begin
565       return Null_Occurrence;
566    end Current_Target_Exception;
567
568    -------------------
569    -- EId_To_String --
570    -------------------
571
572    function EId_To_String (X : Exception_Id) return String
573      renames Stream_Attributes.EId_To_String;
574
575    ------------------
576    -- EO_To_String --
577    ------------------
578
579    --  We use the null string to represent the null occurrence, otherwise we
580    --  output the Exception_Information string for the occurrence.
581
582    function EO_To_String (X : Exception_Occurrence) return String
583      renames Stream_Attributes.EO_To_String;
584
585    ------------------------
586    -- Exception_Identity --
587    ------------------------
588
589    function Exception_Identity
590      (X : Exception_Occurrence) return Exception_Id
591    is
592    begin
593       --  Note that the following test used to be here for the original Ada 95
594       --  semantics, but these were modified by AI-241 to require returning
595       --  Null_Id instead of raising Constraint_Error.
596
597       --  if X.Id = Null_Id then
598       --     raise Constraint_Error;
599       --  end if;
600
601       return X.Id;
602    end Exception_Identity;
603
604    ---------------------------
605    -- Exception_Information --
606    ---------------------------
607
608    function Exception_Information (X : Exception_Occurrence) return String is
609    begin
610       if X.Id = Null_Id then
611          raise Constraint_Error;
612       end if;
613
614       return Exception_Data.Exception_Information (X);
615    end Exception_Information;
616
617    -----------------------
618    -- Exception_Message --
619    -----------------------
620
621    function Exception_Message (X : Exception_Occurrence) return String is
622    begin
623       if X.Id = Null_Id then
624          raise Constraint_Error;
625       end if;
626
627       return X.Msg (1 .. X.Msg_Length);
628    end Exception_Message;
629
630    --------------------
631    -- Exception_Name --
632    --------------------
633
634    function Exception_Name (Id : Exception_Id) return String is
635    begin
636       if Id = null then
637          raise Constraint_Error;
638       end if;
639
640       return To_Ptr (Id.Full_Name) (1 .. Id.Name_Length - 1);
641    end Exception_Name;
642
643    function Exception_Name (X : Exception_Occurrence) return String is
644    begin
645       return Exception_Name (X.Id);
646    end Exception_Name;
647
648    ---------------------------
649    -- Exception_Name_Simple --
650    ---------------------------
651
652    function Exception_Name_Simple (X : Exception_Occurrence) return String is
653       Name : constant String := Exception_Name (X);
654       P    : Natural;
655
656    begin
657       P := Name'Length;
658       while P > 1 loop
659          exit when Name (P - 1) = '.';
660          P := P - 1;
661       end loop;
662
663       --  Return result making sure lower bound is 1
664
665       declare
666          subtype Rname is String (1 .. Name'Length - P + 1);
667       begin
668          return Rname (Name (P .. Name'Length));
669       end;
670    end Exception_Name_Simple;
671
672    --------------------
673    -- Exception_Data --
674    --------------------
675
676    package body Exception_Data is separate;
677    --  This package can be easily dummied out if we do not want the basic
678    --  support for exception messages (such as in Ada 83).
679
680    package body Exception_Propagation is
681
682       procedure Setup_Exception
683         (Excep    : EOA;
684          Current  : EOA;
685          Reraised : Boolean := False)
686       is
687          pragma Warnings (Off, Excep);
688          pragma Warnings (Off, Current);
689          pragma Warnings (Off, Reraised);
690       begin
691          null;
692       end Setup_Exception;
693
694    end Exception_Propagation;
695
696    ----------------------
697    -- Exception_Traces --
698    ----------------------
699
700    package body Exception_Traces is separate;
701    --  Depending on the underlying support for IO the implementation will
702    --  differ. Moreover we would like to dummy out this package in case we do
703    --  not want any exception tracing support. This is why this package is
704    --  separated.
705
706    -----------------------
707    -- Stream Attributes --
708    -----------------------
709
710    package body Stream_Attributes is separate;
711    --  This package can be easily dummied out if we do not want the
712    --  support for streaming Exception_Ids and Exception_Occurrences.
713
714    -----------------------------
715    -- Process_Raise_Exception --
716    -----------------------------
717
718    procedure Process_Raise_Exception (E : Exception_Id) is
719       pragma Inspection_Point (E);
720       --  This is so the debugger can reliably inspect the parameter
721
722       Jumpbuf_Ptr : constant Address := Get_Jmpbuf_Address.all;
723       Excep       : constant EOA := Get_Current_Excep.all;
724
725       procedure builtin_longjmp (buffer : Address; Flag : Integer);
726       pragma No_Return (builtin_longjmp);
727       pragma Import (C, builtin_longjmp, "_gnat_builtin_longjmp");
728
729    begin
730       --  WARNING: There should be no exception handler for this body because
731       --  this would cause gigi to prepend a setup for a new jmpbuf to the
732       --  sequence of statements in case of built-in sjljl. We would then
733       --  always get this new buf in Jumpbuf_Ptr instead of the one for the
734       --  exception we are handling, which would completely break the whole
735       --  design of this procedure.
736
737       --  If the jump buffer pointer is non-null, transfer control using it.
738       --  Otherwise announce an unhandled exception (note that this means that
739       --  we have no finalizations to do other than at the outer level).
740       --  Perform the necessary notification tasks in both cases.
741
742       if Jumpbuf_Ptr /= Null_Address then
743          if not Excep.Exception_Raised then
744             Excep.Exception_Raised := True;
745             Exception_Traces.Notify_Handled_Exception;
746          end if;
747
748          builtin_longjmp (Jumpbuf_Ptr, 1);
749
750       else
751          Exception_Traces.Notify_Unhandled_Exception;
752          Exception_Traces.Unhandled_Exception_Terminate;
753       end if;
754    end Process_Raise_Exception;
755
756    ----------------------------
757    -- Raise_Constraint_Error --
758    ----------------------------
759
760    procedure Raise_Constraint_Error
761      (File : System.Address;
762       Line : Integer)
763    is
764    begin
765       Raise_With_Location_And_Msg
766         (Constraint_Error_Def'Access, File, Line);
767    end Raise_Constraint_Error;
768
769    --------------------------------
770    -- Raise_Constraint_Error_Msg --
771    --------------------------------
772
773    procedure Raise_Constraint_Error_Msg
774      (File : System.Address;
775       Line : Integer;
776       Msg  : System.Address)
777    is
778    begin
779       Raise_With_Location_And_Msg
780         (Constraint_Error_Def'Access, File, Line, Msg);
781    end Raise_Constraint_Error_Msg;
782
783    -------------------------
784    -- Raise_Current_Excep --
785    -------------------------
786
787    procedure Raise_Current_Excep (E : Exception_Id) is
788
789       pragma Inspection_Point (E);
790       --  This is so the debugger can reliably inspect the parameter when
791       --  inserting a breakpoint at the start of this procedure.
792
793       Id : Exception_Id := E;
794       pragma Volatile (Id);
795       pragma Warnings (Off, Id);
796       --  In order to provide support for breakpoints on unhandled exceptions,
797       --  the debugger will also need to be able to inspect the value of E from
798       --  another (inner) frame. So we need to make sure that if E is passed in
799       --  a register, its value is also spilled on stack. For this, we store
800       --  the parameter value in a local variable, and add a pragma Volatile to
801       --  make sure it is spilled. The pragma Warnings (Off) is needed because
802       --  the compiler knows that Id is not referenced and that this use of
803       --  pragma Volatile is peculiar!
804
805    begin
806       Debug_Raise_Exception (E => SSL.Exception_Data_Ptr (E));
807       Process_Raise_Exception (E);
808    end Raise_Current_Excep;
809
810    ---------------------
811    -- Raise_Exception --
812    ---------------------
813
814    procedure Raise_Exception
815      (E       : Exception_Id;
816       Message : String := "")
817    is
818       EF : Exception_Id := E;
819
820    begin
821       --  Raise CE if E = Null_ID (AI-446)
822
823       if E = null then
824          EF := Constraint_Error'Identity;
825       end if;
826
827       --  Go ahead and raise appropriate exception
828
829       Exception_Data.Set_Exception_Msg (EF, Message);
830       Abort_Defer.all;
831       Raise_Current_Excep (EF);
832    end Raise_Exception;
833
834    ----------------------------
835    -- Raise_Exception_Always --
836    ----------------------------
837
838    procedure Raise_Exception_Always
839      (E       : Exception_Id;
840       Message : String := "")
841    is
842    begin
843       Exception_Data.Set_Exception_Msg (E, Message);
844       Abort_Defer.all;
845       Raise_Current_Excep (E);
846    end Raise_Exception_Always;
847
848    -------------------------------------
849    -- Raise_From_Controlled_Operation --
850    -------------------------------------
851
852    procedure Raise_From_Controlled_Operation
853      (X : Ada.Exceptions.Exception_Occurrence)
854    is
855       Prefix   : constant String := "adjust/finalize raised ";
856       Orig_Msg : constant String := Exception_Message (X);
857       New_Msg  : constant String := Prefix & Exception_Name (X);
858
859    begin
860       if Orig_Msg'Length >= Prefix'Length
861         and then
862           Orig_Msg (Orig_Msg'First .. Orig_Msg'First + Prefix'Length - 1) =
863                                                                      Prefix
864       then
865          --  Message already has proper prefix, just re-reraise PROGRAM_ERROR
866
867          Raise_Exception_No_Defer
868            (E       => Program_Error'Identity,
869             Message => Orig_Msg);
870
871       elsif Orig_Msg = "" then
872
873          --  No message present: just provide our own
874
875          Raise_Exception_No_Defer
876            (E       => Program_Error'Identity,
877             Message => New_Msg);
878
879       else
880          --  Message present, add informational prefix
881
882          Raise_Exception_No_Defer
883            (E       => Program_Error'Identity,
884             Message => New_Msg & ": " & Orig_Msg);
885       end if;
886    end Raise_From_Controlled_Operation;
887
888    -------------------------------
889    -- Raise_From_Signal_Handler --
890    -------------------------------
891
892    procedure Raise_From_Signal_Handler
893      (E : Exception_Id;
894       M : System.Address)
895    is
896    begin
897       Exception_Data.Set_Exception_C_Msg (E, M);
898       Abort_Defer.all;
899       Process_Raise_Exception (E);
900    end Raise_From_Signal_Handler;
901
902    -------------------------
903    -- Raise_Program_Error --
904    -------------------------
905
906    procedure Raise_Program_Error
907      (File : System.Address;
908       Line : Integer)
909    is
910    begin
911       Raise_With_Location_And_Msg
912         (Program_Error_Def'Access, File, Line);
913    end Raise_Program_Error;
914
915    -----------------------------
916    -- Raise_Program_Error_Msg --
917    -----------------------------
918
919    procedure Raise_Program_Error_Msg
920      (File : System.Address;
921       Line : Integer;
922       Msg  : System.Address)
923    is
924    begin
925       Raise_With_Location_And_Msg
926         (Program_Error_Def'Access, File, Line, Msg);
927    end Raise_Program_Error_Msg;
928
929    -------------------------
930    -- Raise_Storage_Error --
931    -------------------------
932
933    procedure Raise_Storage_Error
934      (File : System.Address;
935       Line : Integer)
936    is
937    begin
938       Raise_With_Location_And_Msg
939         (Storage_Error_Def'Access, File, Line);
940    end Raise_Storage_Error;
941
942    -----------------------------
943    -- Raise_Storage_Error_Msg --
944    -----------------------------
945
946    procedure Raise_Storage_Error_Msg
947      (File : System.Address;
948       Line : Integer;
949       Msg  : System.Address)
950    is
951    begin
952       Raise_With_Location_And_Msg
953         (Storage_Error_Def'Access, File, Line, Msg);
954    end Raise_Storage_Error_Msg;
955
956    ---------------------------------
957    -- Raise_With_Location_And_Msg --
958    ---------------------------------
959
960    procedure Raise_With_Location_And_Msg
961      (E : Exception_Id;
962       F : System.Address;
963       L : Integer;
964       M : System.Address := System.Null_Address)
965    is
966    begin
967       Exception_Data.Set_Exception_C_Msg (E, F, L, Msg2 => M);
968       Abort_Defer.all;
969       Raise_Current_Excep (E);
970    end Raise_With_Location_And_Msg;
971
972    --------------------
973    -- Raise_With_Msg --
974    --------------------
975
976    procedure Raise_With_Msg (E : Exception_Id) is
977       Excep : constant EOA := Get_Current_Excep.all;
978
979    begin
980       Excep.Exception_Raised := False;
981       Excep.Id               := E;
982       Excep.Num_Tracebacks   := 0;
983       Excep.Cleanup_Flag     := False;
984       Excep.Pid              := Local_Partition_ID;
985       Abort_Defer.all;
986       Raise_Current_Excep (E);
987    end Raise_With_Msg;
988
989    --------------------------------------
990    -- Calls to Run-Time Check Routines --
991    --------------------------------------
992
993    procedure Rcheck_00 (File : System.Address; Line : Integer) is
994    begin
995       Raise_Constraint_Error_Msg (File, Line, Rmsg_00'Address);
996    end Rcheck_00;
997
998    procedure Rcheck_01 (File : System.Address; Line : Integer) is
999    begin
1000       Raise_Constraint_Error_Msg (File, Line, Rmsg_01'Address);
1001    end Rcheck_01;
1002
1003    procedure Rcheck_02 (File : System.Address; Line : Integer) is
1004    begin
1005       Raise_Constraint_Error_Msg (File, Line, Rmsg_02'Address);
1006    end Rcheck_02;
1007
1008    procedure Rcheck_03 (File : System.Address; Line : Integer) is
1009    begin
1010       Raise_Constraint_Error_Msg (File, Line, Rmsg_03'Address);
1011    end Rcheck_03;
1012
1013    procedure Rcheck_04 (File : System.Address; Line : Integer) is
1014    begin
1015       Raise_Constraint_Error_Msg (File, Line, Rmsg_04'Address);
1016    end Rcheck_04;
1017
1018    procedure Rcheck_05 (File : System.Address; Line : Integer) is
1019    begin
1020       Raise_Constraint_Error_Msg (File, Line, Rmsg_05'Address);
1021    end Rcheck_05;
1022
1023    procedure Rcheck_06 (File : System.Address; Line : Integer) is
1024    begin
1025       Raise_Constraint_Error_Msg (File, Line, Rmsg_06'Address);
1026    end Rcheck_06;
1027
1028    procedure Rcheck_07 (File : System.Address; Line : Integer) is
1029    begin
1030       Raise_Constraint_Error_Msg (File, Line, Rmsg_07'Address);
1031    end Rcheck_07;
1032
1033    procedure Rcheck_08 (File : System.Address; Line : Integer) is
1034    begin
1035       Raise_Constraint_Error_Msg (File, Line, Rmsg_08'Address);
1036    end Rcheck_08;
1037
1038    procedure Rcheck_09 (File : System.Address; Line : Integer) is
1039    begin
1040       Raise_Constraint_Error_Msg (File, Line, Rmsg_09'Address);
1041    end Rcheck_09;
1042
1043    procedure Rcheck_10 (File : System.Address; Line : Integer) is
1044    begin
1045       Raise_Constraint_Error_Msg (File, Line, Rmsg_10'Address);
1046    end Rcheck_10;
1047
1048    procedure Rcheck_11 (File : System.Address; Line : Integer) is
1049    begin
1050       Raise_Constraint_Error_Msg (File, Line, Rmsg_11'Address);
1051    end Rcheck_11;
1052
1053    procedure Rcheck_12 (File : System.Address; Line : Integer) is
1054    begin
1055       Raise_Constraint_Error_Msg (File, Line, Rmsg_12'Address);
1056    end Rcheck_12;
1057
1058    procedure Rcheck_13 (File : System.Address; Line : Integer) is
1059    begin
1060       Raise_Constraint_Error_Msg (File, Line, Rmsg_13'Address);
1061    end Rcheck_13;
1062
1063    procedure Rcheck_14 (File : System.Address; Line : Integer) is
1064    begin
1065       Raise_Program_Error_Msg (File, Line, Rmsg_14'Address);
1066    end Rcheck_14;
1067
1068    procedure Rcheck_15 (File : System.Address; Line : Integer) is
1069    begin
1070       Raise_Program_Error_Msg (File, Line, Rmsg_15'Address);
1071    end Rcheck_15;
1072
1073    procedure Rcheck_16 (File : System.Address; Line : Integer) is
1074    begin
1075       Raise_Program_Error_Msg (File, Line, Rmsg_16'Address);
1076    end Rcheck_16;
1077
1078    procedure Rcheck_17 (File : System.Address; Line : Integer) is
1079    begin
1080       Raise_Program_Error_Msg (File, Line, Rmsg_17'Address);
1081    end Rcheck_17;
1082
1083    procedure Rcheck_18 (File : System.Address; Line : Integer) is
1084    begin
1085       Raise_Program_Error_Msg (File, Line, Rmsg_18'Address);
1086    end Rcheck_18;
1087
1088    procedure Rcheck_19 (File : System.Address; Line : Integer) is
1089    begin
1090       Raise_Program_Error_Msg (File, Line, Rmsg_19'Address);
1091    end Rcheck_19;
1092
1093    procedure Rcheck_20 (File : System.Address; Line : Integer) is
1094    begin
1095       Raise_Program_Error_Msg (File, Line, Rmsg_20'Address);
1096    end Rcheck_20;
1097
1098    procedure Rcheck_21 (File : System.Address; Line : Integer) is
1099    begin
1100       Raise_Program_Error_Msg (File, Line, Rmsg_21'Address);
1101    end Rcheck_21;
1102
1103    procedure Rcheck_22 (File : System.Address; Line : Integer) is
1104    begin
1105       Raise_Program_Error_Msg (File, Line, Rmsg_22'Address);
1106    end Rcheck_22;
1107
1108    procedure Rcheck_23 (File : System.Address; Line : Integer) is
1109    begin
1110       Raise_Program_Error_Msg (File, Line, Rmsg_23'Address);
1111    end Rcheck_23;
1112
1113    procedure Rcheck_24 (File : System.Address; Line : Integer) is
1114    begin
1115       Raise_Program_Error_Msg (File, Line, Rmsg_24'Address);
1116    end Rcheck_24;
1117
1118    procedure Rcheck_25 (File : System.Address; Line : Integer) is
1119    begin
1120       Raise_Program_Error_Msg (File, Line, Rmsg_25'Address);
1121    end Rcheck_25;
1122
1123    procedure Rcheck_26 (File : System.Address; Line : Integer) is
1124    begin
1125       Raise_Program_Error_Msg (File, Line, Rmsg_26'Address);
1126    end Rcheck_26;
1127
1128    procedure Rcheck_27 (File : System.Address; Line : Integer) is
1129    begin
1130       Raise_Program_Error_Msg (File, Line, Rmsg_27'Address);
1131    end Rcheck_27;
1132
1133    procedure Rcheck_28 (File : System.Address; Line : Integer) is
1134    begin
1135       Raise_Program_Error_Msg (File, Line, Rmsg_28'Address);
1136    end Rcheck_28;
1137
1138    procedure Rcheck_29 (File : System.Address; Line : Integer) is
1139    begin
1140       Raise_Program_Error_Msg (File, Line, Rmsg_29'Address);
1141    end Rcheck_29;
1142
1143    procedure Rcheck_30 (File : System.Address; Line : Integer) is
1144    begin
1145       Raise_Program_Error_Msg (File, Line, Rmsg_30'Address);
1146    end Rcheck_30;
1147
1148    procedure Rcheck_31 (File : System.Address; Line : Integer) is
1149    begin
1150       Raise_Storage_Error_Msg (File, Line, Rmsg_31'Address);
1151    end Rcheck_31;
1152
1153    procedure Rcheck_32 (File : System.Address; Line : Integer) is
1154    begin
1155       Raise_Storage_Error_Msg (File, Line, Rmsg_32'Address);
1156    end Rcheck_32;
1157
1158    procedure Rcheck_33 (File : System.Address; Line : Integer) is
1159    begin
1160       Raise_Storage_Error_Msg (File, Line, Rmsg_33'Address);
1161    end Rcheck_33;
1162
1163    procedure Rcheck_34 (File : System.Address; Line : Integer) is
1164    begin
1165       Raise_Storage_Error_Msg (File, Line, Rmsg_34'Address);
1166    end Rcheck_34;
1167
1168    -------------
1169    -- Reraise --
1170    -------------
1171
1172    procedure Reraise is
1173       Excep : constant EOA := Get_Current_Excep.all;
1174
1175    begin
1176       Abort_Defer.all;
1177       Raise_Current_Excep (Excep.Id);
1178    end Reraise;
1179
1180    ------------------------
1181    -- Reraise_Occurrence --
1182    ------------------------
1183
1184    procedure Reraise_Occurrence (X : Exception_Occurrence) is
1185    begin
1186       if X.Id /= null then
1187          Abort_Defer.all;
1188          Save_Occurrence_No_Private (Get_Current_Excep.all.all, X);
1189          Raise_Current_Excep (X.Id);
1190       end if;
1191    end Reraise_Occurrence;
1192
1193    -------------------------------
1194    -- Reraise_Occurrence_Always --
1195    -------------------------------
1196
1197    procedure Reraise_Occurrence_Always (X : Exception_Occurrence) is
1198    begin
1199       Abort_Defer.all;
1200       Save_Occurrence_No_Private (Get_Current_Excep.all.all, X);
1201       Raise_Current_Excep (X.Id);
1202    end Reraise_Occurrence_Always;
1203
1204    ---------------------------------
1205    -- Reraise_Occurrence_No_Defer --
1206    ---------------------------------
1207
1208    procedure Reraise_Occurrence_No_Defer (X : Exception_Occurrence) is
1209    begin
1210       Save_Occurrence_No_Private (Get_Current_Excep.all.all, X);
1211       Raise_Current_Excep (X.Id);
1212    end Reraise_Occurrence_No_Defer;
1213
1214    ---------------------
1215    -- Save_Occurrence --
1216    ---------------------
1217
1218    procedure Save_Occurrence
1219      (Target : out Exception_Occurrence;
1220       Source : Exception_Occurrence)
1221    is
1222    begin
1223       Save_Occurrence_No_Private (Target, Source);
1224    end Save_Occurrence;
1225
1226    function Save_Occurrence (Source : Exception_Occurrence) return EOA is
1227       Target : constant EOA := new Exception_Occurrence;
1228    begin
1229       Save_Occurrence (Target.all, Source);
1230       return Target;
1231    end Save_Occurrence;
1232
1233    --------------------------------
1234    -- Save_Occurrence_No_Private --
1235    --------------------------------
1236
1237    procedure Save_Occurrence_No_Private
1238      (Target : out Exception_Occurrence;
1239       Source : Exception_Occurrence)
1240    is
1241    begin
1242       Target.Id             := Source.Id;
1243       Target.Msg_Length     := Source.Msg_Length;
1244       Target.Num_Tracebacks := Source.Num_Tracebacks;
1245       Target.Pid            := Source.Pid;
1246       Target.Cleanup_Flag   := Source.Cleanup_Flag;
1247
1248       Target.Msg (1 .. Target.Msg_Length) :=
1249         Source.Msg (1 .. Target.Msg_Length);
1250
1251       Target.Tracebacks (1 .. Target.Num_Tracebacks) :=
1252         Source.Tracebacks (1 .. Target.Num_Tracebacks);
1253    end Save_Occurrence_No_Private;
1254
1255    -------------------------
1256    -- Transfer_Occurrence --
1257    -------------------------
1258
1259    procedure Transfer_Occurrence
1260      (Target : Exception_Occurrence_Access;
1261       Source : Exception_Occurrence)
1262    is
1263    begin
1264       --  Setup Target as an exception to be propagated in the calling task
1265       --  (rendezvous-wise), taking care not to clobber the associated private
1266       --  data. Target is expected to be a pointer to the calling task's fixed
1267       --  TSD occurrence, which is very different from Get_Current_Excep here
1268       --  because this subprogram is called from the called task.
1269
1270       Save_Occurrence_No_Private (Target.all, Source);
1271    end Transfer_Occurrence;
1272
1273    -------------------
1274    -- String_To_EId --
1275    -------------------
1276
1277    function String_To_EId (S : String) return Exception_Id
1278      renames Stream_Attributes.String_To_EId;
1279
1280    ------------------
1281    -- String_To_EO --
1282    ------------------
1283
1284    function String_To_EO (S : String) return Exception_Occurrence
1285      renames Stream_Attributes.String_To_EO;
1286
1287    ------------------------------
1288    -- Raise_Exception_No_Defer --
1289    ------------------------------
1290
1291    procedure Raise_Exception_No_Defer
1292      (E       : Exception_Id;
1293       Message : String := "")
1294    is
1295    begin
1296       Exception_Data.Set_Exception_Msg (E, Message);
1297
1298       --  Do not call Abort_Defer.all, as specified by the spec
1299
1300       Raise_Current_Excep (E);
1301    end Raise_Exception_No_Defer;
1302
1303    ---------------
1304    -- To_Stderr --
1305    ---------------
1306
1307    procedure To_Stderr (C : Character) is
1308       type int is new Integer;
1309
1310       procedure put_char_stderr (C : int);
1311       pragma Import (C, put_char_stderr, "put_char_stderr");
1312
1313    begin
1314       put_char_stderr (Character'Pos (C));
1315    end To_Stderr;
1316
1317    procedure To_Stderr (S : String) is
1318    begin
1319       for J in S'Range loop
1320          if S (J) /= ASCII.CR then
1321             To_Stderr (S (J));
1322          end if;
1323       end loop;
1324    end To_Stderr;
1325
1326 end Ada.Exceptions;