tree.h (get_containing_scope): Declare it.
authorMark Mitchell <mark@codesourcery.com>
Mon, 8 Nov 1999 15:27:56 +0000 (15:27 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Mon, 8 Nov 1999 15:27:56 +0000 (15:27 +0000)
* 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

gcc/ChangeLog
gcc/toplev.c
gcc/tree.c
gcc/tree.h

index 82ecbc0b01bbc6ae28484efdacb037a9f95bfe71..4b8ccbfbbaec4b23dfa8bf8192a1db105b3c84a8 100644 (file)
@@ -1,4 +1,11 @@
-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.
 
index ef5a1fcdca7728e024a416ddd600e94334656b46..615ee9e08bfd7b2ed28ef7eb27886056c95dc1dc 100644 (file)
@@ -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))
          {
index 1184c6b6f8c99c0c66984bccd2fb25e31609f312..c3a95a6f85a1649909a584f04e729e3dffa65ad7 100644 (file)
@@ -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;
index 477708e4f65a7af0641e233df004ea6fe70fae3a..4af3a1ddb675d767c89dd9ad4de52d6aa656cd4c 100644 (file)
@@ -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));