From: Mark Mitchell Date: Sat, 19 Jun 1999 11:17:56 +0000 (+0000) Subject: decl.c (expand_static_init): When building an anonymous function for use with atexit... X-Git-Tag: prereleases/gcc-2.95-test~190 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c4c5606ed1ce5fece2169fe3b261edb3684cb01;p=thirdparty%2Fgcc.git decl.c (expand_static_init): When building an anonymous function for use with atexit... * decl.c (expand_static_init): When building an anonymous function for use with atexit, compute its body before and after entering the function. From-SVN: r27613 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 67fc9d2d1ac0..32c5e791405d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +1999-06-19 Mark Mitchell + + * decl.c (expand_static_init): When building an anonymous function + for use with atexit, compute its body before and after entering + the function. + 1999-06-18 Mark Mitchell * init.c (expand_aggr_vbase_init): Add flag parameter. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 7ae43dbc3ec2..87c65fdb4c60 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8506,6 +8506,8 @@ expand_static_init (decl, init) { tree cleanup, fcall; static tree Atexit = 0; + int saved_flag_access_control; + if (Atexit == 0) { tree atexit_fndecl, PFV, pfvlist; @@ -8532,13 +8534,31 @@ expand_static_init (decl, init) so that any access checks will be done relative to the current scope, rather than the scope of the anonymous function. */ - fcall = build_cleanup (decl); + build_cleanup (decl); + + /* Now start the function. */ cleanup = start_anon_func (); + + /* Now, recompute the cleanup. It may contain SAVE_EXPRs + that refer to the original function, rather than the + anonymous one. That will make the back-end think that + nested functions are in use, which causes confusion. */ + saved_flag_access_control = flag_access_control; + flag_access_control = 0; + fcall = build_cleanup (decl); + flag_access_control = saved_flag_access_control; + + /* Finish off the function. */ expand_expr_stmt (fcall); end_anon_func (); + + /* Call atexit with the cleanup function. */ mark_addressable (cleanup); cleanup = build_unary_op (ADDR_EXPR, cleanup, 0); - fcall = build_function_call (Atexit, expr_tree_cons (NULL_TREE, cleanup, NULL_TREE)); + fcall = build_function_call (Atexit, + expr_tree_cons (NULL_TREE, + cleanup, + NULL_TREE)); expand_expr_stmt (fcall); }