re PR c++/79822 (ICE with void statement expression)

PR c++/79822
	* constexpr.c (cxx_eval_statement_list): Treat empty ({ }) like
	({ (void) 0; }).

	* g++.dg/cpp0x/constexpr-79822.C: New test.

From-SVN: r245925
This commit is contained in:
Jakub Jelinek 2017-03-06 16:43:51 +01:00 committed by Jakub Jelinek
parent 90d9a8e6ef
commit 345edb3701
4 changed files with 26 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2017-03-06 Jakub Jelinek <jakub@redhat.com>
PR c++/79822
* constexpr.c (cxx_eval_statement_list): Treat empty ({ }) like
({ (void) 0; }).
2017-03-06 Jason Merrill <jason@redhat.com>
Revert "Allow deduction guides to look into primary template."

View File

@ -3725,8 +3725,9 @@ cxx_eval_statement_list (const constexpr_ctx *ctx, tree t,
{
tree_stmt_iterator i;
tree local_target;
/* In a statement-expression we want to return the last value. */
tree r = NULL_TREE;
/* In a statement-expression we want to return the last value.
For empty statement expression return void_node. */
tree r = void_node;
if (!jump_target)
{
local_target = NULL_TREE;

View File

@ -1,3 +1,8 @@
2017-03-06 Jakub Jelinek <jakub@redhat.com>
PR c++/79822
* g++.dg/cpp0x/constexpr-79822.C: New test.
2017-03-06 Richard Biener <rguenther@suse.de>
PR tree-optimization/79894

View File

@ -0,0 +1,12 @@
// PR c++/79822
// { dg-do compile }
// { dg-options "" }
bool
foo ()
{
bool a = ({ }) && false; // { dg-error "could not convert" }
bool b = ({ ; }) && false; // { dg-error "could not convert" }
bool c = ({ (void) 1; }) && false; // { dg-error "could not convert" }
return a && b && c;
}