diff options
author | Tristan Gingold <gingold@adacore.com> | 2013-01-22 09:49:14 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2013-01-22 09:49:14 +0000 |
commit | 48a24fcfc32ab00e84821c25af74252ff26b48b7 (patch) | |
tree | f1a75b650264f804fa309fe17e6de3b9951c26e5 /gcc/ada/gcc-interface/trans.c | |
parent | 7ab53cfdf65cf05ea5c2aeaa6a0d7e27e94ff189 (diff) | |
download | gcc-48a24fcfc32ab00e84821c25af74252ff26b48b7.zip gcc-48a24fcfc32ab00e84821c25af74252ff26b48b7.tar.gz gcc-48a24fcfc32ab00e84821c25af74252ff26b48b7.tar.bz2 |
gigi.h (ADT_unhandled_except_decl, [...]): New.
* gcc-interface/gigi.h (ADT_unhandled_except_decl,
ADT_unhandled_others_decl): New.
(unhandled_others_decl, unhandled_except_decl): Define.
* gcc-interface/trans.c: Include common/common-target.h.
(gigi): Initialize them.
(Subprogram_Body_to_gnu): On SEH targets, wrap the body of the main
function in a try/catch clause.
From-SVN: r195364
Diffstat (limited to 'gcc/ada/gcc-interface/trans.c')
-rw-r--r-- | gcc/ada/gcc-interface/trans.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 6ef6ee8..722ce73 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -37,6 +37,7 @@ #include "bitmap.h" #include "cgraph.h" #include "target.h" +#include "common/common-target.h" #include "ada.h" #include "adadecode.h" @@ -504,6 +505,13 @@ gigi (Node_Id gnat_root, int max_gnat_node, int number_name ATTRIBUTE_UNUSED, Empty); DECL_IGNORED_P (end_handler_decl) = 1; + unhandled_except_decl + = create_subprog_decl (get_identifier ("__gnat_unhandled_except_handler"), + NULL_TREE, + ftype, NULL_TREE, false, true, true, true, NULL, + Empty); + DECL_IGNORED_P (unhandled_except_decl) = 1; + reraise_zcx_decl = create_subprog_decl (get_identifier ("__gnat_reraise_zcx"), NULL_TREE, ftype, NULL_TREE, false, true, true, true, NULL, @@ -639,6 +647,12 @@ gigi (Node_Id gnat_root, int max_gnat_node, int number_name ATTRIBUTE_UNUSED, integer_type_node, NULL_TREE, true, false, true, false, NULL, Empty); + unhandled_others_decl + = create_var_decl (get_identifier ("UNHANDLED_OTHERS"), + get_identifier ("__gnat_unhandled_others_value"), + integer_type_node, NULL_TREE, true, false, true, false, + NULL, Empty); + main_identifier_node = get_identifier ("main"); /* Install the builtins we might need, either internally or as @@ -3495,6 +3509,26 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) set_end_locus_from_node (gnu_result, gnat_node); set_end_locus_from_node (gnu_subprog_decl, gnat_node); + /* On SEH targets, install an exception handler around the main entry + point to catch unhandled exceptions. */ + if (DECL_NAME (gnu_subprog_decl) == main_identifier_node + && targetm_common.except_unwind_info (&global_options) == UI_SEH) + { + tree t; + tree etype; + + t = build_call_expr (builtin_decl_explicit (BUILT_IN_EH_POINTER), + 1, integer_zero_node); + t = build_call_n_expr (unhandled_except_decl, 1, t); + + etype = build_unary_op (ADDR_EXPR, NULL_TREE, unhandled_others_decl); + etype = tree_cons (NULL_TREE, etype, NULL_TREE); + + t = build2 (CATCH_EXPR, void_type_node, etype, t); + gnu_result = build2 (TRY_CATCH_EXPR, TREE_TYPE (gnu_result), + gnu_result, t); + } + end_subprog_body (gnu_result); /* Finally annotate the parameters and disconnect the trees for parameters |