diff options
author | Jason Merrill <jason@redhat.com> | 2020-01-10 13:47:02 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2020-01-10 13:47:02 -0500 |
commit | e0804c9b5efdf17bbfb692a787df36b86f71af8d (patch) | |
tree | 85f98decaabbf13fa0629a17b3dd0716131067bb /gcc/cp/constexpr.c | |
parent | 640b23d7ff5f3fad005dcbfb04a36e27000fc150 (diff) | |
download | gcc-e0804c9b5efdf17bbfb692a787df36b86f71af8d.zip gcc-e0804c9b5efdf17bbfb692a787df36b86f71af8d.tar.gz gcc-e0804c9b5efdf17bbfb692a787df36b86f71af8d.tar.bz2 |
PR c++/93143 - incorrect tree sharing with constexpr.
We don't unshare CONSTRUCTORs as often during constexpr evaluation, so we
need to unshare them here.
* constexpr.c (cxx_eval_outermost_constant_expr): Don't assume
CONSTRUCTORs are already unshared.
From-SVN: r280127
Diffstat (limited to 'gcc/cp/constexpr.c')
-rw-r--r-- | gcc/cp/constexpr.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 9306a7dc..3ca3b9e 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -6347,10 +6347,10 @@ cxx_eval_outermost_constant_expr (tree t, bool allow_non_constant, if (!non_constant_p && overflow_p) non_constant_p = true; - /* Unshare the result unless it's a CONSTRUCTOR in which case it's already - unshared. */ + /* Unshare the result. */ bool should_unshare = true; - if (r == t || TREE_CODE (r) == CONSTRUCTOR) + if (r == t || (TREE_CODE (t) == TARGET_EXPR + && TARGET_EXPR_INITIAL (t) == r)) should_unshare = false; if (non_constant_p && !allow_non_constant) |