diff options
author | Jason Merrill <jason@redhat.com> | 2004-08-27 22:33:54 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2004-08-27 22:33:54 -0400 |
commit | 40aac94801f86355bd86cf5b340481ee2f501d3c (patch) | |
tree | 1f0fd6ce16170d90ee5ebfcb5972ed7af5874607 /gcc/gimplify.c | |
parent | ed3479983db246f3126c12c441659ef6b8ed027e (diff) | |
download | gcc-40aac94801f86355bd86cf5b340481ee2f501d3c.zip gcc-40aac94801f86355bd86cf5b340481ee2f501d3c.tar.gz gcc-40aac94801f86355bd86cf5b340481ee2f501d3c.tar.bz2 |
re PR c++/13684 (local static object variable constructed once but ctors and dtors called multiple times on same memory when called in multiple threads)
PR c++/13684
* cp/decl.c (expand_static_init): Use thread-safety API.
(register_dtor_fn): Return the call, don't expand it.
* cp/tree.c (add_stmt_to_compound): New fn.
(stabilize_call): Use it.
* gimplify.c (gimplify_cleanup_point_expr): Handle CLEANUP_EH_ONLY.
(gimple_push_cleanup): Add eh_only parm.
(gimplify_target_expr): Pass it.
* c.opt (-fno-threadsafe-statics): New option.
* c-opts.c (c_common_handle_option): Handle it.
* c-common.h (flag_threadsafe_statics): Declare it.
* c-common.c (flag_threadsafe_statics): Record it.
* doc/invoke.texi: Document it.
* tsystem.h (_GNU_SOURCE): Define.
* gthr-posix.h (__gthread_recursive_mutex_t): New typedef.
(__GTHREAD_RECURSIVE_MUTEX_INIT): New macro.
(__GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION): New macro.
(__gthread_recursive_mutex_init_function): New fn.
(__gthread_recursive_mutex_lock): New fn.
(__gthread_recursive_mutex_trylock): New fn.
(__gthread_recursive_mutex_unlock): New fn.
* gthr-solaris.h, gthr-single.h, gthr-dce.h: Likewise.
* gthr-win32.h, gthr-vxworks.h: Likewise.
* gthr.h: Document.
* libsupc++/guard.cc (static_mutex): Internal class implementing a
recursive mutex which controls initialization of local statics.
(__gnu_cxx::recursive_init): New exception class.
(__cxa_guard_acquire): Deal with locking and recursion detection.
(acquire_1, __cxa_guard_abort, __cxa_guard_release): Likewise.
From-SVN: r86687
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r-- | gcc/gimplify.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 323df36..2de6cf6 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -3271,9 +3271,15 @@ gimplify_cleanup_point_expr (tree *expr_p, tree *pre_p) else { tree sl, tfe; + enum tree_code code; + + if (CLEANUP_EH_ONLY (wce)) + code = TRY_CATCH_EXPR; + else + code = TRY_FINALLY_EXPR; sl = tsi_split_statement_list_after (&iter); - tfe = build (TRY_FINALLY_EXPR, void_type_node, sl, NULL_TREE); + tfe = build (code, void_type_node, sl, NULL_TREE); append_to_statement_list (TREE_OPERAND (wce, 0), &TREE_OPERAND (tfe, 1)); *wce_p = tfe; @@ -3301,7 +3307,7 @@ gimplify_cleanup_point_expr (tree *expr_p, tree *pre_p) is the cleanup action required. */ static void -gimple_push_cleanup (tree var, tree cleanup, tree *pre_p) +gimple_push_cleanup (tree var, tree cleanup, bool eh_only, tree *pre_p) { tree wce; @@ -3352,6 +3358,7 @@ gimple_push_cleanup (tree var, tree cleanup, tree *pre_p) else { wce = build (WITH_CLEANUP_EXPR, void_type_node, cleanup); + CLEANUP_EH_ONLY (wce) = eh_only; append_to_statement_list (wce, pre_p); } @@ -3399,7 +3406,8 @@ gimplify_target_expr (tree *expr_p, tree *pre_p, tree *post_p) if (TARGET_EXPR_CLEANUP (targ)) { gimplify_stmt (&TARGET_EXPR_CLEANUP (targ)); - gimple_push_cleanup (temp, TARGET_EXPR_CLEANUP (targ), pre_p); + gimple_push_cleanup (temp, TARGET_EXPR_CLEANUP (targ), + CLEANUP_EH_ONLY (targ), pre_p); } /* Only expand this once. */ |