From: Jason Merrill Date: Wed, 7 Jul 2021 21:57:40 +0000 (-0400) Subject: Revert "c++: Improve init handling" X-Git-Tag: releases/gcc-11.2.0~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79663c962588e8c033ff39be39e938e2cc866e12;p=thirdparty%2Fgcc.git 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 --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 0ed15f53596f..9cfe62a98eeb 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 ca4f9a55e5f9..a2d498f82ae7 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 {};