]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Revert "c++: Improve init handling"
authorJason Merrill <jason@redhat.com>
Wed, 7 Jul 2021 21:57:40 +0000 (17:57 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 7 Jul 2021 22:49:55 +0000 (18:49 -0400)
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.

gcc/cp/decl.c
gcc/testsuite/g++.dg/cpp0x/constexpr-empty14.C

index 0ed15f53596f521e1b7f6b7e4d724de060181ca3..9cfe62a98eeb47bf5b2acabeced44a63886a0ec9 100644 (file)
@@ -7052,17 +7052,9 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **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
index ca4f9a55e5f9686c02b1fcbda62cbfd9e1aac93d..a2d498f82ae7e42b0e56e7a62c6a96e176e646e6 100644 (file)
@@ -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 {};