aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constexpr.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2015-06-11 11:45:01 -0400
committerJason Merrill <jason@gcc.gnu.org>2015-06-11 11:45:01 -0400
commitacb2970c3bdf4cfd81954278d28f53adcffab99c (patch)
tree71a96b0f5f11e1781ea2e76086cf3e229938292d /gcc/cp/constexpr.c
parent881a5e608a945bebcfbefcf8c521a2e481610789 (diff)
downloadgcc-acb2970c3bdf4cfd81954278d28f53adcffab99c.zip
gcc-acb2970c3bdf4cfd81954278d28f53adcffab99c.tar.gz
gcc-acb2970c3bdf4cfd81954278d28f53adcffab99c.tar.bz2
re PR c++/66450 ([C++11][constexpr] Issues when delegating implicit copy constructor in constexpr function)
PR c++/66450 * constexpr.c (cxx_eval_store_expression): Avoid messing up outer ctx->ctor. From-SVN: r224381
Diffstat (limited to 'gcc/cp/constexpr.c')
-rw-r--r--gcc/cp/constexpr.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 8fa2eb3..af6b39e 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -2671,11 +2671,13 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t,
}
release_tree_vector (refs);
- if ((AGGREGATE_TYPE_P (TREE_TYPE (t)) || VECTOR_TYPE_P (TREE_TYPE (t))))
+ if (AGGREGATE_TYPE_P (type) || VECTOR_TYPE_P (type))
{
/* Create a new CONSTRUCTOR in case evaluation of the initializer
wants to modify it. */
- *valp = new_ctx.ctor = build_constructor (TREE_TYPE (t), NULL);
+ new_ctx.ctor = build_constructor (type, NULL);
+ if (*valp == NULL_TREE)
+ *valp = new_ctx.ctor;
CONSTRUCTOR_NO_IMPLICIT_ZERO (new_ctx.ctor) = true;
new_ctx.object = target;
}
@@ -2683,8 +2685,16 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t,
init = cxx_eval_constant_expression (&new_ctx, init, false,
non_constant_p, overflow_p);
if (target == object)
- /* The hash table might have moved since the get earlier. */
- ctx->values->put (object, init);
+ {
+ /* The hash table might have moved since the get earlier. */
+ valp = ctx->values->get (object);
+ if (TREE_CODE (init) == CONSTRUCTOR)
+ /* An outer ctx->ctor might be pointing to *valp, so just replace
+ its contents. */
+ CONSTRUCTOR_ELTS (*valp) = CONSTRUCTOR_ELTS (init);
+ else
+ *valp = init;
+ }
else
*valp = init;