Commit 595f1b12 by Jason Merrill

c++: Adjust formatting.

This patch has no semantic effect; committing it separately makes the change
for 94205 easier to read.

gcc/cp/ChangeLog
2020-03-31  Jason Merrill  <jason@redhat.com>

	* constexpr.c (cxx_eval_constant_expression) [TARGET_EXPR]: Use
	local variables.
parent 73dd0518
2020-03-31 Jason Merrill <jason@redhat.com>
* constexpr.c (cxx_eval_constant_expression) [TARGET_EXPR]: Use
local variables.
2020-03-30 Jason Merrill <jason@redhat.com> 2020-03-30 Jason Merrill <jason@redhat.com>
PR c++/90711 PR c++/90711
......
...@@ -5525,36 +5525,41 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -5525,36 +5525,41 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
break; break;
case TARGET_EXPR: case TARGET_EXPR:
if (!literal_type_p (TREE_TYPE (t))) {
tree type = TREE_TYPE (t);
if (!literal_type_p (type))
{ {
if (!ctx->quiet) if (!ctx->quiet)
{ {
auto_diagnostic_group d; auto_diagnostic_group d;
error ("temporary of non-literal type %qT in a " error ("temporary of non-literal type %qT in a "
"constant expression", TREE_TYPE (t)); "constant expression", type);
explain_non_literal_class (TREE_TYPE (t)); explain_non_literal_class (type);
} }
*non_constant_p = true; *non_constant_p = true;
break; break;
} }
gcc_checking_assert (!TARGET_EXPR_DIRECT_INIT_P (t)); gcc_checking_assert (!TARGET_EXPR_DIRECT_INIT_P (t));
/* Avoid evaluating a TARGET_EXPR more than once. */ /* Avoid evaluating a TARGET_EXPR more than once. */
if (tree *p = ctx->global->values.get (TARGET_EXPR_SLOT (t))) tree slot = TARGET_EXPR_SLOT (t);
if (tree *p = ctx->global->values.get (slot))
{ {
if (lval) if (lval)
return TARGET_EXPR_SLOT (t); return slot;
r = *p; r = *p;
break; break;
} }
if ((AGGREGATE_TYPE_P (TREE_TYPE (t)) || VECTOR_TYPE_P (TREE_TYPE (t)))) tree init = TARGET_EXPR_INITIAL (t);
if ((AGGREGATE_TYPE_P (type) || VECTOR_TYPE_P (type)))
{ {
/* We're being expanded without an explicit target, so start /* We're being expanded without an explicit target, so start
initializing a new object; expansion with an explicit target initializing a new object; expansion with an explicit target
strips the TARGET_EXPR before we get here. */ strips the TARGET_EXPR before we get here. */
new_ctx = *ctx; new_ctx = *ctx;
new_ctx.ctor = build_constructor (TREE_TYPE (t), NULL); new_ctx.ctor = build_constructor (type, NULL);
CONSTRUCTOR_NO_CLEARING (new_ctx.ctor) = true; CONSTRUCTOR_NO_CLEARING (new_ctx.ctor) = true;
new_ctx.object = TARGET_EXPR_SLOT (t); new_ctx.object = slot;
ctx->global->values.put (new_ctx.object, new_ctx.ctor); ctx->global->values.put (new_ctx.object, new_ctx.ctor);
ctx = &new_ctx; ctx = &new_ctx;
} }
...@@ -5566,15 +5571,16 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -5566,15 +5571,16 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
if (*non_constant_p) if (*non_constant_p)
break; break;
/* Adjust the type of the result to the type of the temporary. */ /* Adjust the type of the result to the type of the temporary. */
r = adjust_temp_type (TREE_TYPE (t), r); r = adjust_temp_type (type, r);
if (TARGET_EXPR_CLEANUP (t) && !CLEANUP_EH_ONLY (t)) if (TARGET_EXPR_CLEANUP (t) && !CLEANUP_EH_ONLY (t))
ctx->global->cleanups->safe_push (TARGET_EXPR_CLEANUP (t)); ctx->global->cleanups->safe_push (TARGET_EXPR_CLEANUP (t));
r = unshare_constructor (r); r = unshare_constructor (r);
ctx->global->values.put (TARGET_EXPR_SLOT (t), r); ctx->global->values.put (slot, r);
if (ctx->save_exprs) if (ctx->save_exprs)
ctx->save_exprs->safe_push (TARGET_EXPR_SLOT (t)); ctx->save_exprs->safe_push (slot);
if (lval) if (lval)
return TARGET_EXPR_SLOT (t); return slot;
}
break; break;
case INIT_EXPR: case INIT_EXPR:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment