This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: PR6352
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 19 Apr 2002 09:25:13 -0700
- Subject: C++ PATCH: PR6352
- Reply-to: mark at codesourcery dot com
This patch fixes PR 6352, an inlining faiulre in the C++ front end.
I'm not sure quite what changed to cause this test case to abort, but
this is a good way to fix it. When deciding whether to defer a
non-inlinable function, there's no point in deferring a function
that we already know needs to be generated.
Bootstrapped and tested on i686-pc-linux-gnu.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2002-04-19 Mark Mitchell <mark@codesourcery.com>
PR c++/6352
* toplev.c (rest_of_compilation): Do not defer functions for which
TREE_SYMBOL_REFERENCED has already been set.
2002-04-19 Mark Mitchell <mark@codesourcery.com>
* PR6352
* g++.dg/opt/inline2.C: New test.
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.574.2.10
diff -c -p -r1.574.2.10 toplev.c
*** toplev.c 12 Apr 2002 22:46:19 -0000 1.574.2.10
--- toplev.c 18 Apr 2002 17:31:12 -0000
*************** rest_of_compilation (decl)
*** 2449,2454 ****
--- 2449,2455 ----
if (inlinable
|| (DECL_INLINE (decl)
&& ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
+ && ! TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
&& ! flag_keep_inline_functions)
|| DECL_EXTERNAL (decl))))
DECL_DEFER_OUTPUT (decl) = 1;
Index: testsuite/g++.dg/opt/inline2.C
===================================================================
RCS file: testsuite/g++.dg/opt/inline2.C
diff -N testsuite/g++.dg/opt/inline2.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/opt/inline2.C 18 Apr 2002 17:31:19 -0000
***************
*** 0 ****
--- 1,18 ----
+ // { dg-do link }
+ // { dg-options "-O1 -finline-functions" }
+
+ static void g ();
+
+ void f()
+ {
+ void g();
+ g();
+ }
+
+ void g()
+ {
+ }
+
+ int main () {
+ f ();
+ }