aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>1999-11-08 15:27:56 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1999-11-08 15:27:56 +0000
commit140b60b42e92daa02621ec13ebdc691f157b1e99 (patch)
treeaea8894e0a6c088bacdf1a5b13e154d7b0d15e06 /gcc/tree.c
parent8f4f2f295ad85cf42ac03c94549b5341e4d331c8 (diff)
downloadgcc-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.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 1184c6b..c3a95a6 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -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;