]> gcc.gnu.org Git - gcc.git/commitdiff
c-semantics.c (genrtl_scope_stmt): Write out nested inline functions here, instead...
authorMark Mitchell <mark@codesourcery.com>
Wed, 6 Jun 2001 03:08:21 +0000 (03:08 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 6 Jun 2001 03:08:21 +0000 (03:08 +0000)
* c-semantics.c (genrtl_scope_stmt): Write out nested inline
functions here, instead of ...
* c-decl.c (c_expand_body): ... here.

From-SVN: r42930

gcc/ChangeLog
gcc/c-decl.c
gcc/c-semantics.c
gcc/testsuite/gcc.c-torture/execute/20010605-1.c [new file with mode: 0644]

index 3c7cf35bb776ba6bca9443f1ebebe60a8cc9b4fd..77cf39501c42ea32cf8be4124b61b64804d3fce1 100644 (file)
@@ -1,3 +1,9 @@
+2001-06-05  Mark Mitchell  <mark@codesourcery.com>
+
+       * c-semantics.c (genrtl_scope_stmt): Write out nested inline
+       functions here, instead of ...
+       * c-decl.c (c_expand_body): ... here.
+
 2001-06-05  David O'Brien  <obrien@FreeBSD.org>
 
        * config.gcc, config/sparc/bsd.h:  Do not directly include
index e60ab9de785fcdcb5e71df085f8231296d60fc97..378b53e355f63eaf642b9396daf2703001651218 100644 (file)
@@ -6931,19 +6931,8 @@ c_expand_body (fndecl, nested_p)
     }
 
   if (nested_p)
-    {
-      /* Return to the enclosing function.  */
-      pop_function_context ();
-      /* If the nested function was inline, write it out if that is
-        necessary.  */
-      if (!TREE_ASM_WRITTEN (fndecl) && TREE_ADDRESSABLE (fndecl))
-       {
-         push_function_context ();
-         output_inline_function (fndecl);
-         pop_function_context ();
-       }
-    }
-
+    /* Return to the enclosing function.  */
+    pop_function_context ();
 }
 \f
 /* Check the declarations given in a for-loop for satisfying the C99
index 7f88e970acdebee05affaed30004243971cf7778..63b4b14fad52e35e0453d54be2c664367295f07d 100644 (file)
@@ -561,11 +561,12 @@ void
 genrtl_scope_stmt (t)
      tree t;
 {
+  tree block = SCOPE_STMT_BLOCK (t);
+
   if (!SCOPE_NO_CLEANUPS_P (t))
     {
       if (SCOPE_BEGIN_P (t))
-       expand_start_bindings_and_block (2 * SCOPE_NULLIFIED_P (t),
-                                        SCOPE_STMT_BLOCK (t));
+       expand_start_bindings_and_block (2 * SCOPE_NULLIFIED_P (t), block);
       else if (SCOPE_END_P (t))
        expand_end_bindings (NULL_TREE, !SCOPE_NULLIFIED_P (t), 0);
     }
@@ -575,7 +576,27 @@ genrtl_scope_stmt (t)
                            (SCOPE_BEGIN_P (t) 
                             ? NOTE_INSN_BLOCK_BEG
                             : NOTE_INSN_BLOCK_END));
-      NOTE_BLOCK (note) = SCOPE_STMT_BLOCK (t);
+      NOTE_BLOCK (note) = block;
+    }
+
+  /* If we're at the end of a scope that contains inlined nested
+     functions, we have to decide whether or not to write them out.  */
+  if (block && SCOPE_END_P (t))
+    {
+      tree fn;
+
+      for (fn = BLOCK_VARS (block); fn; fn = TREE_CHAIN (fn))
+       {
+         if (TREE_CODE (fn) == FUNCTION_DECL 
+             && DECL_CONTEXT (fn) == current_function_decl
+             && !TREE_ASM_WRITTEN (fn)
+             && TREE_ADDRESSABLE (fn))
+           {
+             push_function_context ();
+             output_inline_function (fn);
+             pop_function_context ();
+           }
+       }
     }
 }
 
diff --git a/gcc/testsuite/gcc.c-torture/execute/20010605-1.c b/gcc/testsuite/gcc.c-torture/execute/20010605-1.c
new file mode 100644 (file)
index 0000000..4bf230b
--- /dev/null
@@ -0,0 +1,11 @@
+int main ()
+{
+  int v = 42;
+
+  static inline int fff (int x)
+    {
+      return x*10;
+    }
+
+  return (fff (v) != 420);
+}
This page took 0.091688 seconds and 5 git commands to generate.