Commit 3f1f0ae3 by Martin Jambor Committed by Martin Jambor

re PR middle-end/45699 (Incorrect copy constructor generated with -O)

2010-10-11  Martin Jambor  <mjambor@suse.cz>

	PR middle-end/45699
	* gimple-fold.c (gimple_fold_obj_type_ref_known_binfo): Choose among
	thunks.

	* testsuite/g++.dg/torture/pr45699.C: New test.
	* testsuite/g++.dg/otr-fold-1.C: Adjusted.
	* testsuite/g++.dg/otr-fold-1.C: Likewise.

From-SVN: r165327
parent 90a2689f
2010-10-11 Martin Jambor <mjambor@suse.cz>
PR middle-end/45699
* gimple-fold.c (gimple_fold_obj_type_ref_known_binfo): Choose among
thunks.
2010-10-11 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> 2010-10-11 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* Makefile.in ($(lang_checks_parallel)) * Makefile.in ($(lang_checks_parallel))
...@@ -1463,7 +1463,7 @@ tree ...@@ -1463,7 +1463,7 @@ tree
gimple_fold_obj_type_ref_known_binfo (HOST_WIDE_INT token, tree known_binfo) gimple_fold_obj_type_ref_known_binfo (HOST_WIDE_INT token, tree known_binfo)
{ {
HOST_WIDE_INT i; HOST_WIDE_INT i;
tree v, fndecl; tree v, fndecl, delta;
v = BINFO_VIRTUALS (known_binfo); v = BINFO_VIRTUALS (known_binfo);
i = 0; i = 0;
...@@ -1475,6 +1475,25 @@ gimple_fold_obj_type_ref_known_binfo (HOST_WIDE_INT token, tree known_binfo) ...@@ -1475,6 +1475,25 @@ gimple_fold_obj_type_ref_known_binfo (HOST_WIDE_INT token, tree known_binfo)
} }
fndecl = TREE_VALUE (v); fndecl = TREE_VALUE (v);
delta = TREE_PURPOSE (v);
gcc_assert (host_integerp (delta, 0));
if (integer_nonzerop (delta))
{
struct cgraph_node *node = cgraph_get_node (fndecl);
HOST_WIDE_INT off = tree_low_cst (delta, 0);
if (!node)
return NULL;
for (node = node->same_body; node; node = node->next)
if (node->thunk.thunk_p && off == node->thunk.fixed_offset)
break;
if (node)
fndecl = node->decl;
else
return NULL;
}
/* When cgraph node is missing and function is not public, we cannot /* When cgraph node is missing and function is not public, we cannot
devirtualize. This can happen in WHOPR when the actual method devirtualize. This can happen in WHOPR when the actual method
ends up in other partition, because we found devirtualization ends up in other partition, because we found devirtualization
......
2010-10-11 Martin Jambor <mjambor@suse.cz>
PR middle-end/45699
* g++.dg/torture/pr45699.C: New test.
* g++.dg/otr-fold-1.C: Adjusted.
* g++.dg/otr-fold-1.C: Likewise.
2010-10-11 Nick Clifton <nickc@redhat.com> 2010-10-11 Nick Clifton <nickc@redhat.com>
* gcc.c-torture/compile/pr44197.c: Require visibility support. * gcc.c-torture/compile/pr44197.c: Require visibility support.
......
...@@ -72,5 +72,5 @@ int main (int argc, char *argv[]) ...@@ -72,5 +72,5 @@ int main (int argc, char *argv[])
return 0; return 0;
} }
/* { dg-final { scan-tree-dump "= B::foo" "optimized" } } */ /* { dg-final { scan-tree-dump "= B::.*foo" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */ /* { dg-final { cleanup-tree-dump "optimized" } } */
...@@ -84,5 +84,5 @@ int main (int argc, char *argv[]) ...@@ -84,5 +84,5 @@ int main (int argc, char *argv[])
return 0; return 0;
} }
/* { dg-final { scan-tree-dump "= B::foo" "optimized" } } */ /* { dg-final { scan-tree-dump "= B::.*foo" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */ /* { dg-final { cleanup-tree-dump "optimized" } } */
// { dg-do run }
extern "C" void abort ();
class A
{
public:
virtual void foo () {abort();}
};
class B : public A
{
public:
int z;
virtual void foo () {abort();}
};
class C : public A
{
public:
void *a[32];
unsigned long b;
long c[32];
virtual void foo () {abort();}
};
class D : public C, public B
{
public:
D () : C(), B()
{
int i;
for (i = 0; i < 32; i++)
{
a[i] = (void *) 0;
c[i] = 0;
}
b = 0xaaaa;
}
virtual void foo ();
};
void D::foo()
{
if (b != 0xaaaa)
abort();
}
static inline void bar (B &b)
{
b.foo ();
}
int main()
{
D d;
bar (d);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment