re PR c++/70615 (ICE on valid code at -O1 and above on x86_64-linux-gnu in add_expr, at tree.c:7870)

PR c++/70615
	* cp-gimplify.c (cp_genericize_r): Expand PTRMEM_CST here.
	(cp_gimplify_expr): Not here.

From-SVN: r234940
This commit is contained in:
Jason Merrill 2016-04-13 10:33:53 -04:00 committed by Jason Merrill
parent 75ca93ec9a
commit 9d4099343a
3 changed files with 44 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2016-04-13 Jason Merrill <jason@redhat.com>
PR c++/70615
* cp-gimplify.c (cp_genericize_r): Expand PTRMEM_CST here.
(cp_gimplify_expr): Not here.
2016-04-12 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/70610

View File

@ -576,11 +576,6 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
switch (code)
{
case PTRMEM_CST:
*expr_p = cplus_expand_constant (*expr_p);
ret = GS_OK;
break;
case AGGR_INIT_EXPR:
simplify_aggr_init_expr (expr_p);
ret = GS_OK;
@ -1388,6 +1383,13 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
|| TREE_CODE (stmt) == OMP_SIMD
|| TREE_CODE (stmt) == OMP_DISTRIBUTE)
genericize_omp_for_stmt (stmt_p, walk_subtrees, data);
else if (TREE_CODE (stmt) == PTRMEM_CST)
{
/* By the time we get here we're handing off to the back end, so we don't
need or want to preserve PTRMEM_CST anymore. */
*stmt_p = cplus_expand_constant (stmt);
*walk_subtrees = 0;
}
else if ((flag_sanitize
& (SANITIZE_NULL | SANITIZE_ALIGNMENT | SANITIZE_VPTR))
&& !wtd->no_sanitize_p)

View File

@ -0,0 +1,31 @@
// PR c++/70615
// { dg-options -O }
struct C
{
virtual void f () {}
};
struct B
{
virtual ~B () {}
};
class D : public B, public C
{
public:
D () {}
};
typedef void (C::*FP) ();
typedef void (D::*D_f) ();
int
main ()
{
D *d = new D ();
C *c = d;
const FP fptr = (FP) & D::f;
(d->*(D_f) fptr) ();
return 0;
}