This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for finding __in_chrg
- To: gcc-patches at gcc dot gnu dot org
- Subject: C++ PATCH for finding __in_chrg
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Fri, 17 Sep 1999 16:50:30 -0700
- Reply-to: mark at codesourcery dot com
It's hokey to look for __in_chrg by name in a destructor, and it
doesn't work in function-at-a-time mode. This patch fixes that.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
1999-09-17 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (language_function): Add x_eh_spec_try_block. Add
x_scope_stmt_stack. Add x_in_charge_parm.
(current_eh_spec_try_block): New macro.
(current_scope_stmt_stack): Likewise.
(current_in_charge_parm): Likewise.
* decl.c (start_function): Initialize current_in_charge_parm.
(finish_function): Use current_in_charge_parm rather than looking
up __in_chrg.
* search.c (expand_indirect_vtbls_init): Likewise.
Index: cp-tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.307
diff -c -p -r1.307 cp-tree.h
*** cp-tree.h 1999/09/17 23:14:46 1.307
--- cp-tree.h 1999/09/17 23:33:19
*************** struct language_function
*** 623,628 ****
--- 623,631 ----
tree x_current_class_ref;
tree x_last_tree;
tree x_last_expr_type;
+ tree x_eh_spec_try_block;
+ tree x_scope_stmt_stack;
+ tree x_in_charge_parm;
struct rtx_def *x_last_dtor_insn;
struct rtx_def *x_last_parm_cleanup_insn;
*************** struct language_function
*** 694,699 ****
--- 697,716 ----
the last expression statement. */
#define last_expr_type cp_function_chain->x_last_expr_type
+
+ /* The TRY_BLOCK for the exception-specifiers for the current
+ function, if any. */
+
+ #define current_eh_spec_try_block cp_function_chain->x_eh_spec_try_block
+
+ /* The stack of SCOPE_STMTs for the current function. */
+
+ #define current_scope_stmt_stack cp_function_chain->x_scope_stmt_stack
+
+ /* The `__in_chrg' parameter for the current function. Only used for
+ destructors. */
+
+ #define current_in_charge_parm cp_function_chain->x_in_charge_parm
/* Set to 0 at beginning of a function definition, set to 1 if
a return statement that specifies a return value is seen. */
Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.457
diff -c -p -r1.457 decl.c
*** decl.c 1999/09/17 23:14:47 1.457
--- decl.c 1999/09/17 23:33:28
*************** start_function (declspecs, declarator, a
*** 13001,13006 ****
--- 13001,13009 ----
= build_indirect_ref (t, NULL_PTR);
cp_function_chain->x_current_class_ptr = t;
+ if (DECL_DESTRUCTOR_P (decl1))
+ current_in_charge_parm = TREE_CHAIN (t);
+
resume_momentary (i);
if (! hack_decl_function_context (decl1))
end_temporary_allocation ();
*************** finish_function (lineno, flags)
*** 13374,13380 ****
tree binfo = TYPE_BINFO (current_class_type);
tree cond = integer_one_node;
tree exprstmt;
- tree in_charge_node = lookup_name (in_charge_identifier, 0);
tree virtual_size;
int ok_to_optimize_dtor = 0;
int empty_dtor = get_last_insn () == last_dtor_insn;
--- 13377,13382 ----
*************** finish_function (lineno, flags)
*** 13424,13430 ****
exprstmt = build_delete (current_class_type, current_class_ref, integer_zero_node,
LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR|LOOKUP_NORMAL, 0);
else
! exprstmt = build_delete (current_class_type, current_class_ref, in_charge_node,
LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR|LOOKUP_NORMAL, 0);
/* If we did not assign to this, then `this' is non-zero at
--- 13426,13434 ----
exprstmt = build_delete (current_class_type, current_class_ref, integer_zero_node,
LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR|LOOKUP_NORMAL, 0);
else
! exprstmt = build_delete (current_class_type,
! current_class_ref,
! current_in_charge_parm,
LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR|LOOKUP_NORMAL, 0);
/* If we did not assign to this, then `this' is non-zero at
*************** finish_function (lineno, flags)
*** 13451,13457 ****
{
tree vbases = nreverse (copy_list (CLASSTYPE_VBASECLASSES (current_class_type)));
expand_start_cond (build (BIT_AND_EXPR, integer_type_node,
! in_charge_node, integer_two_node), 0);
while (vbases)
{
if (TYPE_NEEDS_DESTRUCTOR (BINFO_TYPE (vbases)))
--- 13455,13462 ----
{
tree vbases = nreverse (copy_list (CLASSTYPE_VBASECLASSES (current_class_type)));
expand_start_cond (build (BIT_AND_EXPR, integer_type_node,
! current_in_charge_parm,
! integer_two_node), 0);
while (vbases)
{
if (TYPE_NEEDS_DESTRUCTOR (BINFO_TYPE (vbases)))
*************** finish_function (lineno, flags)
*** 13499,13505 ****
if (exprstmt)
{
cond = build (BIT_AND_EXPR, integer_type_node,
! in_charge_node, integer_one_node);
expand_start_cond (cond, 0);
expand_expr_stmt (exprstmt);
expand_end_cond ();
--- 13504,13510 ----
if (exprstmt)
{
cond = build (BIT_AND_EXPR, integer_type_node,
! current_in_charge_parm, integer_one_node);
expand_start_cond (cond, 0);
expand_expr_stmt (exprstmt);
expand_end_cond ();
Index: search.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/search.c,v
retrieving revision 1.122
diff -c -p -r1.122 search.c
*** search.c 1999/09/09 06:16:40 1.122
--- search.c 1999/09/17 23:33:30
*************** expand_indirect_vtbls_init (binfo, true_
*** 2784,2790 ****
if (fixup_insns)
{
! tree in_charge_node = lookup_name (in_charge_identifier, 0);
if (! in_charge_node)
{
warning ("recoverable internal compiler error, nobody's in charge!");
--- 2784,2790 ----
if (fixup_insns)
{
! tree in_charge_node = current_in_charge_parm;
if (! in_charge_node)
{
warning ("recoverable internal compiler error, nobody's in charge!");