Commit c8816908 by Jason Merrill Committed by Jason Merrill

PR c++/80077 - error with constexpr and -fno-elide-constructors.

	* constexpr.c (cxx_eval_call_expression): Set ctx->call while
	expanding trivial constructor.

From-SVN: r246272
parent a4c9d801
2017-03-19 Jason Merrill <jason@redhat.com>
PR c++/80077 - error with constexpr and -fno-elide-constructors.
* constexpr.c (cxx_eval_call_expression): Set ctx->call while
expanding trivial constructor.
2017-03-17 Jason Merrill <jason@redhat.com> 2017-03-17 Jason Merrill <jason@redhat.com>
PR c++/78345 - ICE initializing array from lambda. PR c++/78345 - ICE initializing array from lambda.
......
...@@ -1478,7 +1478,8 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, ...@@ -1478,7 +1478,8 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
else else
op = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (op)), op); op = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (op)), op);
tree set = build2 (MODIFY_EXPR, TREE_TYPE (op), op, init); tree set = build2 (MODIFY_EXPR, TREE_TYPE (op), op, init);
return cxx_eval_constant_expression (ctx, set, lval, new_ctx.call = &new_call;
return cxx_eval_constant_expression (&new_ctx, set, lval,
non_constant_p, overflow_p); non_constant_p, overflow_p);
} }
} }
...@@ -1496,7 +1497,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, ...@@ -1496,7 +1497,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
} }
/* If in direct recursive call, optimize definition search. */ /* If in direct recursive call, optimize definition search. */
if (ctx && ctx->call && ctx->call->fundef->decl == fun) if (ctx && ctx->call && ctx->call->fundef && ctx->call->fundef->decl == fun)
new_call.fundef = ctx->call->fundef; new_call.fundef = ctx->call->fundef;
else else
{ {
......
// PR c++/80077
// { dg-do compile { target c++11 } }
// { dg-options -fno-elide-constructors }
struct X_t { X_t() = default; };
constexpr X_t x = X_t();
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