From: Mark Mitchell Date: Mon, 8 Nov 1999 15:27:56 +0000 (+0000) Subject: tree.h (get_containing_scope): Declare it. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=140b60b42e92daa02621ec13ebdc691f157b1e99;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 82ecbc0b01b..4b8ccbfbbae 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,11 @@ -Mon Nov 8 03:03:07 1999 Alexandre Oliva +Mon Nov 8 07:25:37 1999 Mark Mitchell + + * 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 * Makefile.in (rtl.o): Depend on toplev.h. diff --git a/gcc/toplev.c b/gcc/toplev.c index ef5a1fcdca7..615ee9e08bf 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -3594,7 +3594,8 @@ rest_of_compilation (decl) 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)) { diff --git a/gcc/tree.c b/gcc/tree.c index 1184c6b6f8c..c3a95a6f85a 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; diff --git a/gcc/tree.h b/gcc/tree.h index 477708e4f65..4af3a1ddb67 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -1950,6 +1950,11 @@ extern tree get_inner_reference PROTO((tree, int *, int *, tree *, 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));