]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/except.h
re PR testsuite/27476 (ACATS: Ada testsuite Bourne shell compatibility problem on...
[thirdparty/gcc.git] / gcc / except.h
CommitLineData
4956d07c 1/* Exception Handling interface routines.
a2130901 2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
02d208ff 3 Free Software Foundation, Inc.
4956d07c
MS
4 Contributed by Mike Stump <mrs@cygnus.com>.
5
1322177d 6This file is part of GCC.
4956d07c 7
1322177d
LB
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
10Software Foundation; either version 2, or (at your option) any later
11version.
4956d07c 12
1322177d
LB
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
4956d07c
MS
17
18You should have received a copy of the GNU General Public License
1322177d 19along with GCC; see the file COPYING. If not, write to the Free
366ccddb
KC
20Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
2102110-1301, USA. */
4956d07c 22
9a0d1e1b 23
f9f6b7df
GS
24struct function;
25
52a11cbf
RH
26/* Per-function EH data. Used only in except.c, but GC and others
27 manipulate pointers to the opaque type. */
28struct eh_status;
911fdd58 29
52a11cbf
RH
30/* Internal structure describing a region. */
31struct eh_region;
ce152ef8 32
52a11cbf 33/* Test: is exception handling turned on? */
502b8322 34extern int doing_eh (int);
ce152ef8 35
b2dd096b
MM
36/* Note that the current EH region (if any) may contain a throw, or a
37 call to a function which itself may contain a throw. */
6de9cd9a
DN
38extern void note_eh_region_may_contain_throw (struct eh_region *);
39extern void note_current_region_may_contain_throw (void);
b2dd096b 40
6a58eee9
RH
41/* Invokes CALLBACK for every exception handler label. Only used by old
42 loop hackery; should not be used by new code. */
502b8322 43extern void for_each_eh_label (void (*) (rtx));
4956d07c 44
f698d217
SB
45/* Invokes CALLBACK for every exception region in the current function. */
46extern void for_each_eh_region (void (*) (struct eh_region *));
47
0519ce30 48/* Determine if the given INSN can throw an exception. */
b59fa6cf 49extern bool can_throw_internal_1 (int, bool);
502b8322 50extern bool can_throw_internal (rtx);
b59fa6cf 51extern bool can_throw_external_1 (int, bool);
502b8322 52extern bool can_throw_external (rtx);
0519ce30 53
97b0ade3 54/* Set TREE_NOTHROW and cfun->all_throwers_are_sibcalls. */
c2924966 55extern unsigned int set_nothrow_function_flags (void);
fb13d4d0 56
52a11cbf
RH
57/* After initial rtl generation, call back to finish generating
58 exception support code. */
502b8322 59extern void finish_eh_generation (void);
fb13d4d0 60
502b8322
AJ
61extern void init_eh (void);
62extern void init_eh_for_function (void);
911fdd58 63
502b8322
AJ
64extern rtx reachable_handlers (rtx);
65extern void maybe_remove_eh_handler (rtx);
e976b8b2 66
502b8322 67extern void convert_from_eh_region_ranges (void);
c2924966 68extern unsigned int convert_to_eh_region_ranges (void);
502b8322
AJ
69extern void find_exception_handler_labels (void);
70extern bool current_function_has_exception_handlers (void);
71extern void output_function_exception_table (void);
154bba13 72
502b8322
AJ
73extern void expand_builtin_unwind_init (void);
74extern rtx expand_builtin_eh_return_data_regno (tree);
75extern rtx expand_builtin_extract_return_addr (tree);
76extern void expand_builtin_init_dwarf_reg_sizes (tree);
77extern rtx expand_builtin_frob_return_addr (tree);
78extern rtx expand_builtin_dwarf_sp_column (void);
79extern void expand_builtin_eh_return (tree, tree);
80extern void expand_eh_return (void);
c76362b4 81extern rtx expand_builtin_extend_pointer (tree);
502b8322 82extern rtx get_exception_pointer (struct function *);
6de9cd9a 83extern rtx get_exception_filter (struct function *);
98f464e0 84typedef tree (*duplicate_eh_regions_map) (tree, void *);
fad41cd7
RH
85extern int duplicate_eh_regions (struct function *, duplicate_eh_regions_map,
86 void *, int, int);
e976b8b2 87
502b8322 88extern void sjlj_emit_function_exit_after (rtx);
617a1b71 89extern void default_init_unwind_resume_libfunc (void);
e976b8b2 90
6de9cd9a
DN
91extern struct eh_region *gen_eh_region_cleanup (struct eh_region *,
92 struct eh_region *);
93extern struct eh_region *gen_eh_region_try (struct eh_region *);
94extern struct eh_region *gen_eh_region_catch (struct eh_region *, tree);
95extern struct eh_region *gen_eh_region_allowed (struct eh_region *, tree);
96extern struct eh_region *gen_eh_region_must_not_throw (struct eh_region *);
97extern int get_eh_region_number (struct eh_region *);
98extern bool get_eh_region_may_contain_throw (struct eh_region *);
99extern tree get_eh_region_tree_label (struct eh_region *);
100extern void set_eh_region_tree_label (struct eh_region *, tree);
101
102extern void foreach_reachable_handler (int, bool,
103 void (*) (struct eh_region *, void *),
104 void *);
105
106extern void collect_eh_region_array (void);
107extern void expand_resx_expr (tree);
cc7220fd
JH
108extern void verify_eh_tree (struct function *);
109extern void dump_eh_tree (FILE *, struct function *);
fad41cd7 110extern bool eh_region_outer_p (struct function *, int, int);
7e2df4a1 111extern int eh_region_outermost (struct function *, int, int);
6de9cd9a
DN
112
113/* tree-eh.c */
b4660e5a
JH
114extern void add_stmt_to_eh_region_fn (struct function *, tree, int);
115extern bool remove_stmt_from_eh_region_fn (struct function *, tree);
116extern int lookup_stmt_eh_region_fn (struct function *, tree);
6de9cd9a 117extern int lookup_stmt_eh_region (tree);
cc7220fd 118extern bool verify_eh_edges (tree);
f54a7f6f 119
e6855a2d 120/* If non-NULL, this is a function that returns an expression to be
a1f300c0 121 executed if an unhandled exception is propagated out of a cleanup
e6855a2d
MM
122 region. For example, in C++, an exception thrown by a destructor
123 during stack unwinding is required to result in a call to
124 `std::terminate', so the C++ version of this function returns a
125 CALL_EXPR for `std::terminate'. */
502b8322 126extern tree (*lang_protect_cleanup_actions) (void);
f54a7f6f 127
52a11cbf 128/* Return true if type A catches type B. */
502b8322 129extern int (*lang_eh_type_covers) (tree a, tree b);
e976b8b2 130
52a11cbf 131/* Map a type to a runtime object to match type. */
502b8322 132extern tree (*lang_eh_runtime_type) (tree);
e976b8b2 133
531073e7
RH
134
135/* Just because the user configured --with-sjlj-exceptions=no doesn't
136 mean that we can use call frame exceptions. Detect that the target
137 has appropriate support. */
138
c14aea87
RO
139#ifndef MUST_USE_SJLJ_EXCEPTIONS
140# if !(defined (EH_RETURN_DATA_REGNO) \
951120ea 141 && (defined (TARGET_UNWIND_INFO) \
84fc8b47 142 || (DWARF2_UNWIND_INFO \
2a1ee410
RH
143 && (defined (EH_RETURN_HANDLER_RTX) \
144 || defined (HAVE_eh_return)))))
c14aea87 145# define MUST_USE_SJLJ_EXCEPTIONS 1
5748beec 146# else
c14aea87 147# define MUST_USE_SJLJ_EXCEPTIONS 0
5748beec 148# endif
52a11cbf
RH
149#endif
150
531073e7
RH
151#ifdef CONFIG_SJLJ_EXCEPTIONS
152# if CONFIG_SJLJ_EXCEPTIONS == 1
153# define USING_SJLJ_EXCEPTIONS 1
154# endif
155# if CONFIG_SJLJ_EXCEPTIONS == 0
156# define USING_SJLJ_EXCEPTIONS 0
52a11cbf
RH
157# ifndef EH_RETURN_DATA_REGNO
158 #error "EH_RETURN_DATA_REGNO required"
159# endif
52a11cbf
RH
160# if !defined(EH_RETURN_HANDLER_RTX) && !defined(HAVE_eh_return)
161 #error "EH_RETURN_HANDLER_RTX or eh_return required"
162# endif
951120ea
PB
163# if !defined(DWARF2_UNWIND_INFO) && !defined(TARGET_UNWIND_INFO)
164 #error "{DWARF2,TARGET}_UNWIND_INFO required"
531073e7
RH
165# endif
166# endif
167#else
52a11cbf 168# define USING_SJLJ_EXCEPTIONS MUST_USE_SJLJ_EXCEPTIONS
531073e7 169#endif
b4660e5a
JH
170
171struct throw_stmt_node GTY(())
172{
173 tree stmt;
174 int region_nr;
175};
176
177extern struct htab *get_eh_throw_stmt_table (struct function *);
178extern void set_eh_throw_stmt_table (struct function *, struct htab *);
736432ee
JL
179
180#ifdef ENABLE_CHECKING
181extern void verify_eh_throw_table_statements (void);
182#endif