This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR43068
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 15 Feb 2010 12:24:13 +0100 (CET)
- Subject: [PATCH] Fix PR43068
This fixes PR43068 by avoiding to fold p p+ 0 in thunk_adjust.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2010-02-15 Richard Guenther <rguenther@suse.de>
PR middle-end/43068
* cgraphunit.c (thunk_adjust): Skip adjusting by fixed_offset
if that is zero.
* g++.dg/torture/pr43068.C: New testcase.
Index: gcc/cgraphunit.c
===================================================================
*** gcc/cgraphunit.c (revision 156733)
--- gcc/cgraphunit.c (working copy)
*************** thunk_adjust (gimple_stmt_iterator * bsi
*** 1230,1236 ****
gimple stmt;
tree ret;
! if (this_adjusting)
{
stmt = gimple_build_assign (ptr,
fold_build2_loc (input_location,
--- 1230,1237 ----
gimple stmt;
tree ret;
! if (this_adjusting
! && fixed_offset != 0)
{
stmt = gimple_build_assign (ptr,
fold_build2_loc (input_location,
*************** thunk_adjust (gimple_stmt_iterator * bsi
*** 1315,1321 ****
offsettmp);
}
! if (!this_adjusting)
/* Adjust the pointer by the constant. */
{
tree ptrtmp;
--- 1316,1323 ----
offsettmp);
}
! if (!this_adjusting
! && fixed_offset != 0)
/* Adjust the pointer by the constant. */
{
tree ptrtmp;
Index: gcc/testsuite/g++.dg/torture/pr43068.C
===================================================================
*** gcc/testsuite/g++.dg/torture/pr43068.C (revision 0)
--- gcc/testsuite/g++.dg/torture/pr43068.C (revision 0)
***************
*** 0 ****
--- 1,10 ----
+ /* { dg-do compile } */
+ /* { dg-options "-freorder-blocks -ftracer} */
+
+ struct A {
+ virtual A *f();
+ };
+ struct B : virtual A {
+ virtual B *f();
+ };
+ B *B::f() { return 0; }