From: Mark Mitchell Date: Tue, 7 Dec 1999 07:49:33 +0000 (+0000) Subject: tree.c (walk_tree): Don't recurse into DECL_INITIAL or DECL_SIZE unless... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b3a44a4c9f0092ea721298c43d93e118bdf4662b;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 812b96654e2..3de35c600b9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +1999-12-06 Mark Mitchell + + * 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 * decl.c (init_decl_processing): #if 0 last patch. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index da15a2867db..1cabf82c127 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;