Commit 140b60b4 by Mark Mitchell Committed by Mark Mitchell

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
parent 8f4f2f29
Mon Nov 8 03:03:07 1999 Alexandre Oliva <oliva@lsd.ic.unicamp.br> Mon Nov 8 07:25:37 1999 Mark Mitchell <mark@codesourcery.com>
* 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.
aMon Nov 8 03:03:07 1999 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
* Makefile.in (rtl.o): Depend on toplev.h. * Makefile.in (rtl.o): Depend on toplev.h.
......
...@@ -3594,7 +3594,8 @@ rest_of_compilation (decl) ...@@ -3594,7 +3594,8 @@ rest_of_compilation (decl)
generating code for this one is not only not necessary but will generating code for this one is not only not necessary but will
confuse some debugging output writers. */ confuse some debugging output writers. */
for (parent = DECL_CONTEXT (current_function_decl); for (parent = DECL_CONTEXT (current_function_decl);
parent != 0; parent = DECL_CONTEXT (parent)) parent != NULL_TREE;
parent = get_containing_scope (parent))
if (TREE_CODE (parent) == FUNCTION_DECL if (TREE_CODE (parent) == FUNCTION_DECL
&& DECL_INLINE (parent) && DECL_EXTERNAL (parent)) && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
{ {
......
...@@ -4772,6 +4772,16 @@ int_fits_type_p (c, type) ...@@ -4772,6 +4772,16 @@ int_fits_type_p (c, type)
&& TREE_UNSIGNED (TREE_TYPE (c)))); && 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 /* Return the innermost context enclosing DECL that is
a FUNCTION_DECL, or zero if none. */ a FUNCTION_DECL, or zero if none. */
...@@ -4791,15 +4801,10 @@ decl_function_context (decl) ...@@ -4791,15 +4801,10 @@ decl_function_context (decl)
while (context && TREE_CODE (context) != FUNCTION_DECL) while (context && TREE_CODE (context) != FUNCTION_DECL)
{ {
if (TREE_CODE_CLASS (TREE_CODE (context)) == 't') if (TREE_CODE (context) == BLOCK)
context = TYPE_CONTEXT (context);
else if (TREE_CODE_CLASS (TREE_CODE (context)) == 'd')
context = DECL_CONTEXT (context);
else if (TREE_CODE (context) == BLOCK)
context = BLOCK_SUPERCONTEXT (context); context = BLOCK_SUPERCONTEXT (context);
else else
/* Unhandled CONTEXT !? */ context = get_containing_scope (context);
abort ();
} }
return context; return context;
......
...@@ -1950,6 +1950,11 @@ extern tree get_inner_reference PROTO((tree, int *, int *, tree *, ...@@ -1950,6 +1950,11 @@ extern tree get_inner_reference PROTO((tree, int *, int *, tree *,
enum machine_mode *, int *, enum machine_mode *, int *,
int *, int *)); int *, int *));
/* Given a DECL or TYPE, return the scope in which it was declared, or
NUL_TREE if there is no containing scope. */
extern tree get_containing_scope PROTO((tree));
/* Return the FUNCTION_DECL which provides this _DECL with its context, /* Return the FUNCTION_DECL which provides this _DECL with its context,
or zero if none. */ or zero if none. */
extern tree decl_function_context PROTO((tree)); extern tree decl_function_context PROTO((tree));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment