]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/ada/a-exexpr.adb
re PR testsuite/39696 (gcc.dg/tree-ssa/ssa-ccp-25.c scan-tree-dump doesn't work on...
[thirdparty/gcc.git] / gcc / ada / a-exexpr.adb
CommitLineData
fbf5a39b
AC
1------------------------------------------------------------------------------
2-- --
3-- GNAT COMPILER COMPONENTS --
4-- --
9f4fd324 5-- A D A . E X C E P T I O N S . E X C E P T I O N _ P R O P A G A T I O N --
fbf5a39b
AC
6-- --
7-- B o d y --
8-- --
0dd8a0b1 9-- Copyright (C) 1992-2008, Free Software Foundation, Inc. --
fbf5a39b
AC
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 --
cb5fee25
KC
19-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20-- Boston, MA 02110-1301, USA. --
fbf5a39b
AC
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
982f26e4
AC
34-- This is the default version, using the __builtin_setjmp/longjmp EH
35-- mechanism.
fbf5a39b 36
5453d5bd
AC
37with System.Storage_Elements; use System.Storage_Elements;
38
fbf5a39b
AC
39pragma Warnings (Off);
40-- Since several constructs give warnings in 3.14a1, including unreferenced
41-- variables and pragma Unreferenced itself.
42
43separate (Ada.Exceptions)
44package body Exception_Propagation is
45
982f26e4
AC
46 procedure builtin_longjmp (buffer : Address; Flag : Integer);
47 pragma No_Return (builtin_longjmp);
48 pragma Import (C, builtin_longjmp, "_gnat_builtin_longjmp");
5453d5bd 49
fbf5a39b
AC
50 ---------------------
51 -- Setup_Exception --
52 ---------------------
53
fbf5a39b
AC
54 procedure Setup_Exception
55 (Excep : EOA;
56 Current : EOA;
57 Reraised : Boolean := False)
58 is
982f26e4 59 pragma Unreferenced (Excep, Current, Reraised);
fbf5a39b 60 begin
8fc789c8 61 -- In the GNAT-SJLJ case this "stack" only exists implicitly, by way of
982f26e4
AC
62 -- local occurrence declarations together with save/restore operations
63 -- generated by the front-end, and this routine has nothing to do.
0da2c8ac 64
fbf5a39b 65 null;
982f26e4 66 end Setup_Exception;
fbf5a39b
AC
67
68 -------------------------
69 -- Propagate_Exception --
70 -------------------------
71
6f301919
AC
72 procedure Propagate_Exception
73 (E : Exception_Id;
74 From_Signal_Handler : Boolean)
75 is
76 pragma Inspection_Point (E);
77
982f26e4
AC
78 Jumpbuf_Ptr : constant Address := Get_Jmpbuf_Address.all;
79 Excep : constant EOA := Get_Current_Excep.all;
fbf5a39b 80 begin
982f26e4
AC
81 -- Compute the backtrace for this occurrence if corresponding binder
82 -- option has been set. Call_Chain takes care of the reraise case.
fbf5a39b 83
982f26e4 84 Call_Chain (Excep);
fbf5a39b 85
982f26e4 86 -- Note on above call to Call_Chain:
fbf5a39b 87
982f26e4
AC
88 -- We used to only do this if From_Signal_Handler was not set,
89 -- based on the assumption that backtracing from a signal handler
90 -- would not work due to stack layout oddities. However, since
fbf5a39b 91
982f26e4
AC
92 -- 1. The flag is never set in tasking programs (Notify_Exception
93 -- performs regular raise statements), and
fbf5a39b 94
982f26e4
AC
95 -- 2. No problem has shown up in tasking programs around here so
96 -- far, this turned out to be too strong an assumption.
fbf5a39b 97
982f26e4 98 -- As, in addition, the test was
fbf5a39b 99
982f26e4
AC
100 -- 1. preventing the production of backtraces in non-tasking
101 -- programs, and
fbf5a39b 102
982f26e4
AC
103 -- 2. introducing a behavior inconsistency between
104 -- the tasking and non-tasking cases,
fbf5a39b 105
982f26e4 106 -- we have simply removed it
fbf5a39b 107
982f26e4
AC
108 -- If the jump buffer pointer is non-null, transfer control using
109 -- it. Otherwise announce an unhandled exception (note that this
110 -- means that we have no finalizations to do other than at the outer
111 -- level). Perform the necessary notification tasks in both cases.
fbf5a39b 112
982f26e4
AC
113 if Jumpbuf_Ptr /= Null_Address then
114 if not Excep.Exception_Raised then
115 Excep.Exception_Raised := True;
116 Exception_Traces.Notify_Handled_Exception;
117 end if;
fbf5a39b 118
982f26e4 119 builtin_longjmp (Jumpbuf_Ptr, 1);
fbf5a39b 120
982f26e4
AC
121 else
122 Exception_Traces.Notify_Unhandled_Exception;
123 Exception_Traces.Unhandled_Exception_Terminate;
fbf5a39b 124 end if;
fbf5a39b
AC
125 end Propagate_Exception;
126
fbf5a39b 127end Exception_Propagation;