Commit 49c8bc0c by Jason Merrill Committed by Jason Merrill

re PR c++/64547 (A non-const constexpr function is rejected incorrectly)

	PR c++/64547
	* constexpr.c (cxx_eval_call_expression): A call to a void
	function doesn't need to return a value.

From-SVN: r219466
parent 9a4fbc59
2015-01-12 Jason Merrill <jason@redhat.com>
PR c++/64547
* constexpr.c (cxx_eval_call_expression): A call to a void
function doesn't need to return a value.
2015-01-09 Michael Collison <michael.collison@linaro.org> 2015-01-09 Michael Collison <michael.collison@linaro.org>
* call.c: Include hash-set.h, machmode.h, vec.h, double-int.h, * call.c: Include hash-set.h, machmode.h, vec.h, double-int.h,
......
...@@ -1386,6 +1386,8 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, ...@@ -1386,6 +1386,8 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
value by evaluating *this, but we don't bother; there's value by evaluating *this, but we don't bother; there's
no need to put such a call in the hash table. */ no need to put such a call in the hash table. */
result = lval ? ctx->object : ctx->ctor; result = lval ? ctx->object : ctx->ctor;
else if (VOID_TYPE_P (TREE_TYPE (res)))
result = void_node;
else else
{ {
result = *ctx->values->get (slot ? slot : res); result = *ctx->values->get (slot ? slot : res);
......
// PR c++/64547
// { dg-do compile { target c++14 } }
struct X
{
int x;
constexpr int get() const {return x;}
constexpr void set(int foo) {x = foo;}
};
constexpr int bar()
{
X x{42};
x.set(666);
return x.get();
}
int main()
{
constexpr int foo = bar();
}
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