diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-05-24 21:06:53 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-05-24 21:06:53 +0000 |
commit | e71bb66286730c556d173664c18ba349c9beb52a (patch) | |
tree | 95fca72cd903c1c0c3ca197d74d3ecc22425ab16 | |
parent | 47609c1288298396ddac700fd80d25e72b92ffec (diff) | |
download | gcc-e71bb66286730c556d173664c18ba349c9beb52a.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@236670 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/cp-gimplify.c | 20 |
2 files changed, 21 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5e7eb3d0e4c..8010cb70b94 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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> PR c++/71147 diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index eeba26829b7..0ba5aa956ee 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -1878,13 +1878,21 @@ cp_fully_fold (tree x) static tree cp_fold_maybe_rvalue (tree x, bool rval) { - if (rval && DECL_P (x)) + while (true) { - tree v = decl_constant_value (x); - if (v != error_mark_node) - x = v; + x = cp_fold (x); + if (rval && DECL_P (x)) + { + 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. */ @@ -2001,7 +2009,7 @@ cp_fold (tree x) if (REF_PARENTHESIZED_P (x)) { tree p = maybe_undo_parenthesized_ref (x); - return cp_fold_maybe_rvalue (p, rval_ops); + return cp_fold (p); } goto unary; |