This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: PR c++/39380: Regression: all programs that link Java and C++ libraries fail when optimized


This is a fairly simple approach to fixing the error described in
http://gcc.gnu.org/ml/gcc/2009-03/msg00068.html.

We detect Java exceptions being used and don't inline functions unless
they are explicitly marked inline.  This is crude but effective.  It
also has the virtue of not affecting anything unless CNI is in use.
It's a little heavy-handed since not all maybe-inlined functions
necessarily will contain catch blocks.

Bootstrapped x86_64-linux-gnu.
OK for trunk?

Andrew.


2009-03-04  Andrew Haley  <aph@redhat.com>

	PR C++/39380
	* decl2.c (possibly_inlined_p): If java exceptions are in use
	don't inline a decl unless it is explicitly marked inline.
	* lex.c: (pragma_java_exceptions): New variable.
	(handle_pragma_java_exceptions): Set pragma_java_exceptions.
	* cp-tree.h (pragma_java_exceptions): Declare new variable.

Index: cp/cp-tree.h
===================================================================
--- cp/cp-tree.h	(revision 143890)
+++ cp/cp-tree.h	(working copy)
@@ -4166,6 +4166,9 @@
    e.g  "int f(void)".  */
 extern cp_parameter_declarator *no_parameters;

+/* True if we saw "#pragma GCC java_exceptions".  */
+extern int pragma_java_exceptions;
+
 /* in call.c */
 extern bool check_dtor_name			(tree, tree);

Index: cp/lex.c
===================================================================
--- cp/lex.c	(revision 143890)
+++ cp/lex.c	(working copy)
@@ -81,6 +81,8 @@

 static struct impl_files *impl_file_chain;

+/* True if we saw "#pragma GCC java_exceptions".  */
+int pragma_java_exceptions;
 
 void
 cxx_finish (void)
@@ -430,6 +432,7 @@
     warning (0, "junk at end of #pragma GCC java_exceptions");

   choose_personality_routine (lang_java);
+  pragma_java_exceptions = 1;
 }

 /* Issue an error message indicating that the lookup of NAME (an
Index: cp/decl2.c
===================================================================
--- cp/decl2.c	(revision 143890)
+++ cp/decl2.c	(working copy)
@@ -3757,7 +3757,7 @@
   gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
   if (DECL_UNINLINABLE (decl))
     return false;
-  if (!optimize)
+  if (!optimize || pragma_java_exceptions)
     return DECL_DECLARED_INLINE_P (decl);
   /* When optimizing, we might inline everything when flatten
      attribute or heuristics inlining for size or autoinlining


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]