re PR c++/84192 (ICE with statement expression)

PR c++/84192
	* constexpr.c (cxx_eval_constant_expression) <case RETURN_EXPR>: Don't
	set *jump_target to anything if jump_target is NULL.

	* g++.dg/cpp1y/constexpr-84192.C: New test.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>

From-SVN: r257770
This commit is contained in:
Marek Polacek 2018-02-16 22:38:53 +00:00 committed by Jakub Jelinek
parent 28f247e6e0
commit 019e0ae8e0
4 changed files with 64 additions and 1 deletions

View file

@ -1,3 +1,10 @@
2018-02-16 Marek Polacek <polacek@redhat.com>
Jakub Jelinek <jakub@redhat.com>
PR c++/84192
* constexpr.c (cxx_eval_constant_expression) <case RETURN_EXPR>: Don't
set *jump_target to anything if jump_target is NULL.
2018-02-16 Jason Merrill <jason@redhat.com>
PR c++/84151 - unnecessary volatile load with static member.

View file

@ -4254,7 +4254,16 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0),
lval,
non_constant_p, overflow_p);
*jump_target = t;
if (jump_target)
*jump_target = t;
else
{
/* Can happen with ({ return true; }) && false; passed to
maybe_constant_value. There is nothing to jump over in this
case, and the bug will be diagnosed later. */
gcc_assert (ctx->quiet);
*non_constant_p = true;
}
break;
case SAVE_EXPR:

View file

@ -1,3 +1,9 @@
2018-02-16 Marek Polacek <polacek@redhat.com>
Jakub Jelinek <jakub@redhat.com>
PR c++/84192
* g++.dg/cpp1y/constexpr-84192.C: New test.
2018-02-16 Martin Sebor <msebor@redhat.com>
PR c++/79064

View file

@ -0,0 +1,41 @@
// PR c++/84192
// { dg-do compile { target c++14 } }
// { dg-options "" }
bool
f1 ()
{
return ({ return true; }) && false; // { dg-error "could not convert" }
}
void
f2 ()
{
for (;;)
constexpr bool b = ({ break; false; }) && false; // { dg-error "statement is not a constant expression" }
}
constexpr bool
f3 (int n)
{
bool b = false;
for (int i = 0; i < n; i++)
b = ({ break; }); // { dg-error "void value not ignored as it ought to be" }
return b;
}
constexpr bool b = f3 (4);
bool
f4 ()
{
constexpr bool b = ({ return true; }) && false; // { dg-error "could not convert" }
return false;
}
constexpr bool
f5 (int x)
{
constexpr bool b = ({ switch (x) case 0: true; }) && false; // { dg-error "could not convert" }
return false;
}