From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id 463B73972402; Wed, 7 Jul 2021 22:50:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 463B73972402 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-8705] Revert "c++: Improve init handling" X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 38fed4dfa25ac4894546f0589340ebfc5eef3bee X-Git-Newrev: 79663c962588e8c033ff39be39e938e2cc866e12 Message-Id: <20210707225013.463B73972402@sourceware.org> Date: Wed, 7 Jul 2021 22:50:13 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Jul 2021 22:50:13 -0000 https://gcc.gnu.org/g:79663c962588e8c033ff39be39e938e2cc866e12 commit r11-8705-g79663c962588e8c033ff39be39e938e2cc866e12 Author: Jason Merrill Date: Wed Jul 7 17:57:40 2021 -0400 Revert "c++: Improve init handling" Apparently looking through these codes means that in a template, we end up feeding a TARGET_EXPR to fold_non_dependent_expr, which should never happen. This is a broader issue, but for now let's just revert the change. This reverts commit d9288bd28e24c755a7216311ee5247e7c88270a6. PR c++/101072 gcc/cp/ChangeLog: * decl.c (check_initializer): Don't look through STMT_EXPR and BIND_EXPR. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/constexpr-empty14.C: Add -fno-elide-constructors. Diff: --- gcc/cp/decl.c | 14 +++----------- gcc/testsuite/g++.dg/cpp0x/constexpr-empty14.C | 1 + 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 0ed15f53596..9cfe62a98ee 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7052,17 +7052,9 @@ check_initializer (tree decl, tree init, int flags, vec **cleanups) have returned an INIT_EXPR rather than a CALL_EXPR. In that case, pull the initializer back out and pass it down into store_init_value. */ - while (true) - { - if (TREE_CODE (init_code) == EXPR_STMT - || TREE_CODE (init_code) == STMT_EXPR - || TREE_CODE (init_code) == CONVERT_EXPR) - init_code = TREE_OPERAND (init_code, 0); - else if (TREE_CODE (init_code) == BIND_EXPR) - init_code = BIND_EXPR_BODY (init_code); - else - break; - } + while (TREE_CODE (init_code) == EXPR_STMT + || TREE_CODE (init_code) == CONVERT_EXPR) + init_code = TREE_OPERAND (init_code, 0); if (TREE_CODE (init_code) == INIT_EXPR) { /* In C++20, the call to build_aggr_init could have created diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-empty14.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty14.C index ca4f9a55e5f..a2d498f82ae 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-empty14.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty14.C @@ -1,5 +1,6 @@ // PR c++/91953 // { dg-do compile { target c++11 } } +// { dg-additional-options -fno-elide-constructors { target c++14_down } } struct S {};