This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [rfa] fix c++/13693
- From: Richard Henderson <rth at redhat dot com>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Jason Merrill <jason at redhat dot com>
- Date: Fri, 30 Jan 2004 15:38:24 -0800
- Subject: Re: [rfa] fix c++/13693
- References: <20040130015324.GA17125@redhat.com> <401A0950.5030002@codesourcery.com>
On Thu, Jan 29, 2004 at 11:35:44PM -0800, Mark Mitchell wrote:
> We really just shouldn't call force_target_expr if the return value from
> the thunk satisfies VOID_TYPE_P. I think you should just change
> use_thunk not to call force_target_expr in that case and have
> target_expr use my_friendly_assert to check that we're not trying to
> make a VOID_TYPE_P TARGET_EXPR. If that works, that patch is certainly
> OK for mainline.
Thanks. Here's the revised patch I committed.
r~
PR c++/13693
* method.c (use_thunk): Don't force_target_expr for void thunks.
* tree.c (build_target_expr_with_type): Assert non-void type.
(force_target_expr): Likewise.
Index: method.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/method.c,v
retrieving revision 1.224.2.24
diff -c -p -d -r1.224.2.24 method.c
*** method.c 3 Jan 2004 23:03:13 -0000 1.224.2.24
--- method.c 30 Jan 2004 23:33:31 -0000
*************** use_thunk (tree thunk_fndecl, bool emit_
*** 487,501 ****
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);
if (VOID_TYPE_P (TREE_TYPE (t)))
finish_expr_stmt (t);
else
! finish_return_stmt (t);
/* Since we want to emit the thunk, we explicitly mark its name as
referenced. */
--- 487,503 ----
t = tree_cons (NULL_TREE, a, t);
t = nreverse (t);
t = build_call (alias, t);
if (VOID_TYPE_P (TREE_TYPE (t)))
finish_expr_stmt (t);
else
! {
! t = force_target_expr (TREE_TYPE (t), t);
! if (!this_adjusting)
! t = thunk_adjust (t, /*this_adjusting=*/0,
! fixed_offset, virtual_offset);
! finish_return_stmt (t);
! }
/* Since we want to emit the thunk, we explicitly mark its name as
referenced. */
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/tree.c,v
retrieving revision 1.286.2.41
diff -c -p -d -r1.286.2.41 tree.c
*** tree.c 3 Jan 2004 23:03:17 -0000 1.286.2.41
--- tree.c 30 Jan 2004 23:33:32 -0000
*************** build_target_expr_with_type (tree init,
*** 318,323 ****
--- 318,325 ----
{
tree slot;
+ my_friendly_assert (!VOID_TYPE_P (type), 20040130);
+
if (TREE_CODE (init) == TARGET_EXPR)
return init;
else if (CLASS_TYPE_P (type) && !TYPE_HAS_TRIVIAL_INIT_REF (type)
*************** build_target_expr_with_type (tree init,
*** 342,348 ****
tree
force_target_expr (tree type, tree init)
{
! tree slot = build_local_temp (type);
return build_target_expr (slot, init);
}
--- 344,354 ----
tree
force_target_expr (tree type, tree init)
{
! tree slot;
!
! my_friendly_assert (!VOID_TYPE_P (type), 20040130);
!
! slot = build_local_temp (type);
return build_target_expr (slot, init);
}