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.
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')
/* 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;
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;