From c6e7c499a3f6dfd86b8b88cb1bdd70a1ebb76012 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 23 Jan 2015 11:29:46 -0500 Subject: [PATCH] =?utf8?q?re=20PR=20c++/64701=20(internal=20compiler=20err?= =?utf8?q?or:=20unexpected=20expression=20=E2=80=98=E2=80=99=20?= =?utf8?q?of=20kind=20do=5Fstmt)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit PR c++/64701 * constexpr.c (maybe_constant_value): Just hand back STATEMENT_LIST. From-SVN: r220046 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/constexpr.c | 14 ++++++++++++-- gcc/testsuite/g++.dg/ext/stmtexpr17.C | 9 +++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/stmtexpr17.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b1d4965cc39..98bbcbd5a07 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2015-01-23 Jason Merrill + PR c++/64701 + * constexpr.c (maybe_constant_value): Just hand back STATEMENT_LIST. + PR c++/64727 * constexpr.c (cxx_eval_constant_expression): Allow for lvalue use of CONST_DECL. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index f144ab01d24..f1434207520 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -3454,8 +3454,18 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, break; default: - internal_error ("unexpected expression %qE of kind %s", t, - get_tree_code_name (TREE_CODE (t))); + if (STATEMENT_CODE_P (TREE_CODE (t))) + { + /* This function doesn't know how to deal with pre-genericize + statements; this can only happen with statement-expressions, + so for now just fail. */ + if (!ctx->quiet) + error_at (EXPR_LOCATION (t), + "statement is not a constant-expression"); + } + else + internal_error ("unexpected expression %qE of kind %s", t, + get_tree_code_name (TREE_CODE (t))); *non_constant_p = true; break; } diff --git a/gcc/testsuite/g++.dg/ext/stmtexpr17.C b/gcc/testsuite/g++.dg/ext/stmtexpr17.C new file mode 100644 index 00000000000..c1640e4fd25 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/stmtexpr17.C @@ -0,0 +1,9 @@ +// PR c++/64701 +// { dg-options "" } + +enum { A }; +void +foo () +{ + int x = ({ do {} while (0); A; }); +} -- 2.30.2