C++ PATCH for New failing g++ test in lastest snapshots.
Mark Mitchell
mark@markmitchell.com
Fri Oct 16 14:06:00 GMT 1998
Here's a fix for this problem. We should do access checks required
for the cleanup before entering the scope of the magic anonymous
function.
--
Mark Mitchell mark@markmitchell.com
Mark Mitchell Consulting http://www.markmitchell.com
1998-10-16 Mark Mitchell <mark@markmitchell.com>
* decl.c (expand_static_init): Build cleanups before entering the
anonymous function used to do them to avoid access-checking
confusion.
Index: testsuite/g++.old-deja/g++.other/static3.C
===================================================================
RCS file: static3.C
diff -N static3.C
*** /dev/null Mon Dec 31 20:00:00 1979
--- static3.C Fri Oct 16 13:45:13 1998
***************
*** 0 ****
--- 1,14 ----
+ // Build don't link:
+
+ class S
+ {
+ ~S();
+ public:
+ friend void f();
+ };
+
+
+ S::~S()
+ {
+ static S s;
+ }
Index: cp/decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.234
diff -c -p -r1.234 decl.c
*** decl.c 1998/10/16 12:07:54 1.234
--- decl.c 1998/10/16 20:45:55
*************** expand_static_init (decl, init)
*** 7814,7821 ****
pop_obstacks ();
}
cleanup = start_anon_func ();
! expand_expr_stmt (build_cleanup (decl));
end_anon_func ();
mark_addressable (cleanup);
cleanup = build_unary_op (ADDR_EXPR, cleanup, 0);
--- 7814,7826 ----
pop_obstacks ();
}
+ /* Call build_cleanup before we enter the anonymous function
+ 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);
cleanup = start_anon_func ();
! expand_expr_stmt (fcall);
end_anon_func ();
mark_addressable (cleanup);
cleanup = build_unary_op (ADDR_EXPR, cleanup, 0);
More information about the Gcc-patches
mailing list