From: Jakub Jelinek Date: Mon, 6 Mar 2017 15:43:51 +0000 (+0100) Subject: re PR c++/79822 (ICE with void statement expression) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=345edb3701a0e99d10a532736f27675846ca5dec;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fc9757b294b..12d74a6702f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-03-06 Jakub Jelinek + + PR c++/79822 + * constexpr.c (cxx_eval_statement_list): Treat empty ({ }) like + ({ (void) 0; }). + 2017-03-06 Jason Merrill Revert "Allow deduction guides to look into primary template." diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 81489570d28..f114da0d9a7 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 35eb8183e43..23adcd1884f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-03-06 Jakub Jelinek + + PR c++/79822 + * g++.dg/cpp0x/constexpr-79822.C: New test. + 2017-03-06 Richard Biener PR tree-optimization/79894 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-79822.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-79822.C new file mode 100644 index 00000000000..6a72702aad8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-79822.C @@ -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; +}