aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>1999-12-07 07:49:33 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1999-12-07 07:49:33 +0000
commitb3a44a4c9f0092ea721298c43d93e118bdf4662b (patch)
treea0a8de69806c8f3530a583b6782cd3c52c017968 /gcc
parent2fb9811eacce6e68f6a05a63e11bbcb03f7002c5 (diff)
downloadgcc-b3a44a4c9f0092ea721298c43d93e118bdf4662b.zip
gcc-b3a44a4c9f0092ea721298c43d93e118bdf4662b.tar.gz
gcc-b3a44a4c9f0092ea721298c43d93e118bdf4662b.tar.bz2
tree.c (walk_tree): Don't recurse into DECL_INITIAL or DECL_SIZE unless...
* tree.c (walk_tree): Don't recurse into DECL_INITIAL or DECL_SIZE unless we're declaring the variable in question. From-SVN: r30816
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/tree.c21
2 files changed, 22 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 812b966..3de35c6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
1999-12-06 Mark Mitchell <mark@codesourcery.com>
+ * tree.c (walk_tree): Don't recurse into DECL_INITIAL or DECL_SIZE
+ unless we're declaring the variable in question.
+
+1999-12-06 Mark Mitchell <mark@codesourcery.com>
+
* decl.c (init_decl_processing): #if 0 last patch.
(finish_function): Likewise.
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index da15a28..1cabf82 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1618,7 +1618,7 @@ walk_tree (tp, func, data)
code = TREE_CODE (*tp);
- /* Handle commmon cases up front. */
+ /* Handle common cases up front. */
if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code))
|| TREE_CODE_CLASS (code) == 'r'
|| TREE_CODE_CLASS (code) == 's')
@@ -1632,7 +1632,22 @@ walk_tree (tp, func, data)
/* For statements, we also walk the chain so that we cover the
entire statement tree. */
if (statement_code_p (code))
- WALK_SUBTREE (TREE_CHAIN (*tp));
+ {
+ if (code == DECL_STMT
+ && DECL_STMT_DECL (*tp)
+ && TREE_CODE_CLASS (TREE_CODE (DECL_STMT_DECL (*tp))) == 'd')
+ {
+ /* Walk the DECL_INITIAL and DECL_SIZE. We don't want to walk
+ into declarations that are just mentioned, rather than
+ declared; they don't really belong to this part of the tree.
+ And, we can see cycles: the initializer for a declaration can
+ refer to the declaration itself. */
+ WALK_SUBTREE (DECL_INITIAL (DECL_STMT_DECL (*tp)));
+ WALK_SUBTREE (DECL_SIZE (DECL_STMT_DECL (*tp)));
+ }
+
+ WALK_SUBTREE (TREE_CHAIN (*tp));
+ }
/* We didn't find what we were looking for. */
return NULL_TREE;
@@ -1640,8 +1655,6 @@ walk_tree (tp, func, data)
else if (TREE_CODE_CLASS (code) == 'd')
{
WALK_SUBTREE (TREE_TYPE (*tp));
- WALK_SUBTREE (DECL_INITIAL (*tp));
- WALK_SUBTREE (DECL_SIZE (*tp));
/* We didn't find what we were looking for. */
return NULL_TREE;