(is_body_block): Rewritten for greater saftey.
authorrms <rms@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 24 Jul 1992 03:30:02 +0000 (03:30 +0000)
committerrms <rms@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 24 Jul 1992 03:30:02 +0000 (03:30 +0000)
(output_block):  Fixed to deal correctly with non-inlined blocks.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@1678 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/dwarfout.c

index a6d80f0..b1f48f5 100644 (file)
@@ -1091,23 +1091,34 @@ output_signed_leb128 (value)
 /**************** utility functions for attribute functions ******************/
 
 /* Given a pointer to a BLOCK node return non-zero if (and only if) the
-   node in question represents the outermost block (i.e. the "body block")
-   of a function or method.
-
-   For any BLOCK node representing a "body block", the BLOCK_SUPERCONTEXT
-   of the node will point to another BLOCK node which represents the outer-
-   most (function) scope for the function or method.  The BLOCK_SUPERCONTEXT
-   of that node in turn will point to the relevant FUNCTION_DECL node.
+   node in question represents the outermost pair of curly braces (i.e.
+   the "body block") of a function or method.
+
+   For any BLOCK node representing a "body block" of a function or method,
+   the BLOCK_SUPERCONTEXT of the node will point to another BLOCK node
+   which represents the outermost (function) scope for the function or
+   method (i.e. the one which includes the formal parameters).  The
+   BLOCK_SUPERCONTEXT of *that* node in turn will point to the relevant
+   FUNCTION_DECL node.
 */
 
 inline int
 is_body_block (stmt)
      register tree stmt;
 {
-  register enum tree_code code
-    = TREE_CODE (BLOCK_SUPERCONTEXT (BLOCK_SUPERCONTEXT (stmt)));
+  if (TREE_CODE (stmt) == BLOCK)
+    {
+      register tree parent = BLOCK_SUPERCONTEXT (stmt);
+
+      if (TREE_CODE (parent) == BLOCK)
+       {
+         register tree grandparent = BLOCK_SUPERCONTEXT (parent);
 
-  return (code == FUNCTION_DECL);
+         if (TREE_CODE (grandparent) == FUNCTION_DECL)
+           return 1;
+       }
+    }
+  return 0;
 }
 
 /* Given a pointer to a tree node for some type, return a Dwarf fundamental
@@ -4047,9 +4058,7 @@ output_block (stmt)
         not represent a "body block inlining" before trying to set the
         `must_output_die' flag.  */
 
-      if (origin != NULL
-         && origin_code == BLOCK
-         && ! is_body_block (origin))
+      if (origin == NULL || ! is_body_block (origin))
        {
          /* Determine if this block directly contains any "significant"
             local declarations which we will need to output DIEs for.  */