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]

[C++] Fix infinite recursion in generic thunk handling


This patch is a tentative fix for g++.jason/thunk1.C and g++.jason/thunk2.
They started failing on MIPS (and presumably other targets that use the
generic thunk handling) after the patch for 11878:

2003-10-14  Jason Merrill  <jason@redhat.com>

	PR c++/11878
	* tree.c (build_target_expr_with_type): Call force_rvalue for
	classes with non-trivial copy ctors.

use_thunk() will build up a call to the real function and then pass that
CALL_EXPR directly to finish_return_stmt().  If the function returns a
non-POD type X, and the call expression is C, we end up calling X's
constructor with C as its argument.  build_over_call() then indirectly
calls build_target_expr_with_type (C, TREE_TYPE (C)).

Before the patch for 11878, b_t_e_w_t() would create a temporary and
initialise it with C, but it now passes C to force_rvalue, which tries
to build the same call to X::X (C).

As that explanation probably proved, I don't really understand the C++
front end.  But judging from what the old code did, and from the recent
changes to builtin_trap, I wondered whether we should unconditionally
create a target_expr for the call.  Doing so seems to fix the testcases
for MIPS.

Tested on mipsisa64-elf.  Is it OK?

Richard


	PR target/12729
	* method.c (use_thunk): Pass the CALL_EXPR through force_target_expr.

Index: cp/method.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/method.c,v
retrieving revision 1.273
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.273 method.c
*** cp/method.c	12 Dec 2003 18:22:22 -0000	1.273
--- cp/method.c	15 Dec 2003 23:20:52 -0000
*************** use_thunk (tree thunk_fndecl, bool emit_
*** 487,492 ****
--- 487,493 ----
  	t = tree_cons (NULL_TREE, a, t);
        t = nreverse (t);
        t = build_call (alias, t);
+       t = force_target_expr (TREE_TYPE (t), t);
        if (!this_adjusting)
  	t = thunk_adjust (t, /*this_adjusting=*/0,
  			  fixed_offset, virtual_offset);


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