This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Fix PR 938
- To: gcc-patches at gcc dot gnu dot org
- Subject: PATCH: Fix PR 938
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Tue, 05 Jun 2001 20:06:20 -0700
- Organization: CodeSourcery, LLC
PR938 refers to a regression where we failed to emit the body of a
nested inline function when necessary.
Tested on i686-pc-linux-gnu, installed on the mainline and on the
branch.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
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.
Index: testsuite/gcc.c-torture/execute/20010605-1.c
===================================================================
RCS file: 20010605-1.c
diff -N 20010605-1.c
*** /dev/null Tue May 5 13:32:27 1998
--- 20010605-1.c Tue Jun 5 19:56:03 2001
***************
*** 0 ****
--- 1,11 ----
+ int main ()
+ {
+ int v = 42;
+
+ static inline int fff (int x)
+ {
+ return x*10;
+ }
+
+ return (fff (v) != 420);
+ }
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.207.2.12
diff -c -p -r1.207.2.12 c-decl.c
*** c-decl.c 2001/06/05 06:47:32 1.207.2.12
--- c-decl.c 2001/06/06 02:55:51
*************** c_expand_body (fndecl, nested_p)
*** 6852,6870 ****
}
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 ();
! }
! }
!
}
/* Check the declarations given in a for-loop for satisfying the C99
--- 6852,6859 ----
}
if (nested_p)
! /* Return to the enclosing function. */
! pop_function_context ();
}
/* Check the declarations given in a for-loop for satisfying the C99
Index: c-semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-semantics.c,v
retrieving revision 1.17.4.2
diff -c -p -r1.17.4.2 c-semantics.c
*** c-semantics.c 2001/03/27 04:41:15 1.17.4.2
--- c-semantics.c 2001/06/06 02:55:51
*************** void
*** 631,641 ****
genrtl_scope_stmt (t)
tree 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));
else if (SCOPE_END_P (t))
expand_end_bindings (NULL_TREE, !SCOPE_NULLIFIED_P (t), 0);
}
--- 631,642 ----
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), block);
else if (SCOPE_END_P (t))
expand_end_bindings (NULL_TREE, !SCOPE_NULLIFIED_P (t), 0);
}
*************** genrtl_scope_stmt (t)
*** 645,651 ****
(SCOPE_BEGIN_P (t)
? NOTE_INSN_BLOCK_BEG
: NOTE_INSN_BLOCK_END));
! NOTE_BLOCK (note) = SCOPE_STMT_BLOCK (t);
}
}
--- 646,672 ----
(SCOPE_BEGIN_P (t)
? NOTE_INSN_BLOCK_BEG
: NOTE_INSN_BLOCK_END));
! 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 ();
! }
! }
}
}