diff options
author | Mark Mitchell <mark@codesourcery.com> | 1999-11-08 15:27:56 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1999-11-08 15:27:56 +0000 |
commit | 140b60b42e92daa02621ec13ebdc691f157b1e99 (patch) | |
tree | aea8894e0a6c088bacdf1a5b13e154d7b0d15e06 /gcc/tree.c | |
parent | 8f4f2f295ad85cf42ac03c94549b5341e4d331c8 (diff) | |
download | gcc-140b60b42e92daa02621ec13ebdc691f157b1e99.zip gcc-140b60b42e92daa02621ec13ebdc691f157b1e99.tar.gz gcc-140b60b42e92daa02621ec13ebdc691f157b1e99.tar.bz2 |
tree.h (get_containing_scope): Declare it.
* tree.h (get_containing_scope): Declare it.
* tree.c (get_containing_scope): New fucntion.
(decl_function_context): Use it.
* toplev.c (rest_of_compilation): Use get_containing_scope.
From-SVN: r30449
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -4772,6 +4772,16 @@ int_fits_type_p (c, type) && TREE_UNSIGNED (TREE_TYPE (c)))); } +/* Given a DECL or TYPE, return the scope in which it was declared, or + NUL_TREE if there is no containing scope. */ + +tree +get_containing_scope (t) + tree t; +{ + return (TYPE_P (t) ? TYPE_CONTEXT (t) : DECL_CONTEXT (t)); +} + /* Return the innermost context enclosing DECL that is a FUNCTION_DECL, or zero if none. */ @@ -4791,15 +4801,10 @@ decl_function_context (decl) while (context && TREE_CODE (context) != FUNCTION_DECL) { - if (TREE_CODE_CLASS (TREE_CODE (context)) == 't') - context = TYPE_CONTEXT (context); - else if (TREE_CODE_CLASS (TREE_CODE (context)) == 'd') - context = DECL_CONTEXT (context); - else if (TREE_CODE (context) == BLOCK) + if (TREE_CODE (context) == BLOCK) context = BLOCK_SUPERCONTEXT (context); - else - /* Unhandled CONTEXT !? */ - abort (); + else + context = get_containing_scope (context); } return context; |