PR c++/70584 - don't force indirection to an rvalue

* cp-gimplify.c (cp_fold_maybe_rvalue): Loop in case cp_fold
	returns a decl.
	(cp_fold) [INDIRECT_REF]: Don't fold to an rvalue.

From-SVN: r236670
This commit is contained in:
Jason Merrill 2016-05-24 17:06:53 -04:00 committed by Jason Merrill
parent 732eb07625
commit 66f90a1761
2 changed files with 21 additions and 6 deletions

View File

@ -1,3 +1,10 @@
2016-05-24 Jason Merrill <jason@redhat.com>
PR c++/70584
* cp-gimplify.c (cp_fold_maybe_rvalue): Loop in case cp_fold
returns a decl.
(cp_fold) [INDIRECT_REF]: Don't fold to an rvalue.
2016-05-24 Martin Sebor <msebor@redhat.com> 2016-05-24 Martin Sebor <msebor@redhat.com>
PR c++/71147 PR c++/71147

View File

@ -1878,13 +1878,21 @@ cp_fully_fold (tree x)
static tree static tree
cp_fold_maybe_rvalue (tree x, bool rval) cp_fold_maybe_rvalue (tree x, bool rval)
{ {
if (rval && DECL_P (x)) while (true)
{ {
tree v = decl_constant_value (x); x = cp_fold (x);
if (v != error_mark_node) if (rval && DECL_P (x))
x = v; {
tree v = decl_constant_value (x);
if (v != x && v != error_mark_node)
{
x = v;
continue;
}
}
break;
} }
return cp_fold (x); return x;
} }
/* Fold expression X which is used as an rvalue. */ /* Fold expression X which is used as an rvalue. */
@ -2001,7 +2009,7 @@ cp_fold (tree x)
if (REF_PARENTHESIZED_P (x)) if (REF_PARENTHESIZED_P (x))
{ {
tree p = maybe_undo_parenthesized_ref (x); tree p = maybe_undo_parenthesized_ref (x);
return cp_fold_maybe_rvalue (p, rval_ops); return cp_fold (p);
} }
goto unary; goto unary;