This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] BLOCK_VARS and tag_transparent level
- From: Devang Patel <dpatel at apple dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 24 Jul 2003 15:24:12 -0700
- Subject: [C++ PATCH] BLOCK_VARS and tag_transparent level
If type of a local variable has non-trival destructor then
'tag_transparent' level is pushed to take care of clean up.
Now during poplevel we need to merge BLOCK_VARS from this
transparent level into outer level. Without this, in following
example debugging info will put variables 'a', 'b' and 'c'
in different blocks.
template <class T> class my_stack {
T* v;
public:
my_stack () { }
~my_stack () { }
};
typedef my_stack<int> TS;
TS ts;
void foo()
{
long s = 0;
{
unsigned long a = 0;
switch (a)
{
case 0: break;
default: break;
}
my_stack<int> b;
int c = -1;
while (c < a)
{
int d;
c++;
}
}
}
Bootstrapped and tested. Did not find any new gdb regression
(for stabs and dwarf) on x86-linux. I gave this example to
our local gdb guys, so hopefully it will show up in FSF gdb
test suite some day.
2002-07-24 Devang Patel <dpatel@apple.com>
* decl.c (poplevel): Merge BLOCK_VARS from tag_transparent
level.
OK to commit ?
Thank you,
--
Devang
Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1096
diff -Idpatel.pbxuser -c -3 -p -r1.1096 decl.c
*** decl.c 22 Jul 2003 23:30:14 -0000 1.1096
--- decl.c 24 Jul 2003 22:07:38 -0000
*************** poplevel (int keep, int reverse, int fun
*** 1521,1526 ****
--- 1521,1527 ----
if (tmp == 2)
{
tree scope_stmts;
+ tree saved_block;
scope_stmts
= add_scope_stmt (/*begin_p=*/0, /*partial_p=*/1);
*************** poplevel (int keep, int reverse, int fun
*** 1530,1536 ****
--- 1531,1545 ----
SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmts)) = block;
}
+ if (block)
+ saved_block = block;
+
block = poplevel (keep, reverse, functionbody);
+
+ /* Merge BLOCK_VARS from tag_transparent block into current
+ block. */
+ BLOCK_VARS (block) = chainon (BLOCK_VARS (block), BLOCK_VARS
(saved_block));
+ BLOCK_VARS (saved_block) = NULL_TREE;
}
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, block);