From 6a980eed7f73516828ac5bb52f23bf6585b85e8a Mon Sep 17 00:00:00 2001 From: mmitchel Date: Thu, 17 May 2001 18:07:36 +0000 Subject: [PATCH] * except.h (protect_cleanup_actions): Remove it. (lang_protect_cleanup_actions): Declare it. * except.c (protect_cleanup_actions): Remove it. (lang_protect_cleanup_actions): New variable. (init_eh): Don't make protect_cleanup_actions a GC root. (expand_eh_region_and_cleanup): Call lang_protect_cleanup_actions. (output_function_exception_table): Remove unused `align' variable. * varasm.c (assemble_external): Abort if we have not yet opened the assembly output file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-3_0-branch@42217 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 14 ++++++++++++++ gcc/cp/ChangeLog | 6 ++++++ gcc/cp/except.c | 17 +++++++++++++++-- gcc/except.c | 13 ++++++++++--- gcc/except.h | 9 +++++++-- gcc/varasm.c | 7 +++++++ 6 files changed, 59 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 06595a71c83..2e715906065 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2001-05-17 Mark Mitchell + + * except.h (protect_cleanup_actions): Remove it. + (lang_protect_cleanup_actions): Declare it. + * except.c (protect_cleanup_actions): Remove it. + (lang_protect_cleanup_actions): New variable. + (init_eh): Don't make protect_cleanup_actions a GC root. + (expand_eh_region_and_cleanup): Call + lang_protect_cleanup_actions. + (output_function_exception_table): Remove unused `align' + variable. + * varasm.c (assemble_external): Abort if we have not yet + opened the assembly output file. + Thu May 17 11:53:49 2001 Jeffrey A Law (law@cygnus.com) * except.c (sjlj_emit_function_enter): Call assemble_external_libcall diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9e84fffed3f..7007fb59c6f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2001-05-17 Mark Mitchell + + * except.c (cp_protect_cleanup_actions): New function. + (init_exception_processing): Don't set protect_cleanup_actions + here. Do set lang_protect_cleanup_actions. + 2001-05-16 Nathan Sidwell * spew.c (read_token): Call yyerror on all unexpected tokens. diff --git a/gcc/cp/except.c b/gcc/cp/except.c index aa372c8ed25..5f408c7384f 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -50,6 +50,7 @@ static int complete_ptr_ref_or_void_ptr_p PARAMS ((tree, tree)); static bool is_admissible_throw_operand PARAMS ((tree)); static int can_convert_eh PARAMS ((tree, tree)); static void check_handlers_1 PARAMS ((tree, tree)); +static tree cp_protect_cleanup_actions PARAMS ((void)); #include "decl.h" #include "obstack.h" @@ -73,8 +74,6 @@ init_exception_processing () if (flag_honor_std) pop_namespace (); - protect_cleanup_actions = build_call (terminate_node, NULL_TREE); - /* void __cxa_call_unexpected(void *); */ tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); tmp = build_function_type (void_type_node, tmp); @@ -86,8 +85,22 @@ init_exception_processing () : "__gxx_personality_v0"); lang_eh_runtime_type = build_eh_type_type; + lang_protect_cleanup_actions = &cp_protect_cleanup_actions; } +/* Returns an expression to be executed if an unhandled exception is + propogated out of a cleanup region. */ + +static tree +cp_protect_cleanup_actions () +{ + /* [except.terminate] + + When the destruction of an object during stack unwinding exits + using an exception ... void terminate(); is called. */ + return build_call (terminate_node, NULL_TREE); +} + static tree prepare_eh_type (type) tree type; diff --git a/gcc/except.c b/gcc/except.c index 4050949cebb..48efbf9b8fc 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -88,7 +88,7 @@ int flag_non_call_exceptions; /* Protect cleanup actions with must-not-throw regions, with a call to the given failure handler. */ -tree protect_cleanup_actions; +tree (*lang_protect_cleanup_actions) PARAMS ((void)); /* Return true if type A catches type B. */ int (*lang_eh_type_covers) PARAMS ((tree a, tree b)); @@ -367,7 +367,6 @@ void init_eh () { ggc_add_rtx_root (&exception_handler_labels, 1); - ggc_add_tree_root (&protect_cleanup_actions, 1); if (! flag_exceptions) return; @@ -691,6 +690,7 @@ expand_eh_region_end_cleanup (handler) tree handler; { struct eh_region *region; + tree protect_cleanup_actions; rtx around_label; rtx data_save[2]; @@ -707,6 +707,13 @@ expand_eh_region_end_cleanup (handler) emit_label (region->label); + /* Give the language a chance to specify an action to be taken if an + exception is thrown that would propogate out of the HANDLER. */ + protect_cleanup_actions + = (lang_protect_cleanup_actions + ? (*lang_protect_cleanup_actions) () + : NULL_TREE); + if (protect_cleanup_actions) expand_eh_region_start (); @@ -3563,7 +3570,7 @@ output_function_exception_table () ASM_OUTPUT_LABEL (asm_out_file, ttype_after_disp_label); #else /* Ug. Alignment queers things. */ - unsigned int before_disp, after_disp, last_disp, disp, align; + unsigned int before_disp, after_disp, last_disp, disp; before_disp = 1 + 1; after_disp = (1 + size_of_uleb128 (call_site_len) diff --git a/gcc/except.h b/gcc/except.h index e0c8c2e6959..2720241d9a6 100644 --- a/gcc/except.h +++ b/gcc/except.h @@ -147,8 +147,13 @@ extern int duplicate_eh_regions PARAMS ((struct function *, extern void sjlj_emit_function_exit_after PARAMS ((rtx)); -/* Nonzero to protect cleanup actions with must-not-throw regions. */ -extern tree protect_cleanup_actions; +/* If non-NULL, this is a function that returns an expression to be + executed if an unhandled exception is propogated out of a cleanup + region. For example, in C++, an exception thrown by a destructor + during stack unwinding is required to result in a call to + `std::terminate', so the C++ version of this function returns a + CALL_EXPR for `std::terminate'. */ +extern tree (*lang_protect_cleanup_actions) PARAMS ((void)); /* Return true if type A catches type B. */ extern int (*lang_eh_type_covers) PARAMS ((tree a, tree b)); diff --git a/gcc/varasm.c b/gcc/varasm.c index f3a9141703d..f8cfe1fb249 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1625,6 +1625,13 @@ void assemble_external (decl) tree decl ATTRIBUTE_UNUSED; { + /* Because most platforms do not define ASM_OUTPUT_EXTERNAL, the + main body of this code is only rarely exercised. To provide some + testing, on all platforms, we make sure that the ASM_OUT_FILE is + open. If it's not, we should not be calling this function. */ + if (!asm_out_file) + abort (); + #ifdef ASM_OUTPUT_EXTERNAL if (DECL_P (decl) && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl)) { -- 2.11.4.GIT