* 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
-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.
generating code for this one is not only not necessary but will
confuse some debugging output writers. */
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
&& DECL_INLINE (parent) && DECL_EXTERNAL (parent))
{
&& 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. */
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;
enum machine_mode *, 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,
or zero if none. */
extern tree decl_function_context PROTO((tree));