]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (expand_static_init): When building an anonymous function for use with atexit...
authorMark Mitchell <mark@codesourcery.com>
Sat, 19 Jun 1999 11:17:56 +0000 (11:17 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sat, 19 Jun 1999 11:17:56 +0000 (11:17 +0000)
* 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

gcc/cp/ChangeLog
gcc/cp/decl.c

index 67fc9d2d1ac05abce0f4566f74f08d40ef60b229..32c5e791405deb70a8d9eec74e5b61f3bbf5494f 100644 (file)
@@ -1,3 +1,9 @@
+1999-06-19  Mark Mitchell  <mark@codesourcery.com>
+
+       * 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  <mark@codesourcery.com>
 
        * init.c (expand_aggr_vbase_init): Add flag parameter.
index 7ae43dbc3ec24f610acac59bdc365bb2a30dc6f7..87c65fdb4c608c630acacdef75ebcfcccd7cc927 100644 (file)
@@ -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);
        }