c++: Revert unnecessary parts of fix for [PR90996]
authorPatrick Palka <ppalka@redhat.com>
Fri, 15 May 2020 18:50:17 +0000 (14:50 -0400)
committerPatrick Palka <ppalka@redhat.com>
Fri, 15 May 2020 18:50:17 +0000 (14:50 -0400)
The process_init_constructor_array part of my PR90996 patch turns out to
be neither necessary nor sufficient to make the pr90996.C testcase work,
and I wasn't able to come up with a testcase that demonstrates this part
is ever necessary.

gcc/cp/ChangeLog:

Revert:

2020-04-07  Patrick Palka  <ppalka@redhat.com>

PR c++/90996
* typeck2.c (process_init_constructor_array): Propagate
CONSTRUCTOR_PLACEHOLDER_BOUNDARY up from each element
initializer to the array initializer.

gcc/testsuite/ChangeLog:

PR c++/90996
* g++.dg/cpp1y/pr90996.C: Turn into execution test to verify
that each PLACEHOLDER_EXPR gets correctly resolved.

gcc/cp/ChangeLog
gcc/cp/typeck2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/pr90996.C

index 732be07c9c0243b6bac8b803c42810d6a09142df..acd2d7be844e879b54da958efa1bd57e8c3bb2de 100644 (file)
@@ -1,3 +1,14 @@
+2020-05-15  Patrick Palka  <ppalka@redhat.com>
+
+       Revert:
+
+       2020-04-07  Patrick Palka  <ppalka@redhat.com>
+
+       PR c++/90996
+       * typeck2.c (process_init_constructor_array): Propagate
+       CONSTRUCTOR_PLACEHOLDER_BOUNDARY up from each element initializer to
+       the array initializer.
+
 2020-05-15  Jason Merrill  <jason@redhat.com>
 
        PR c++/93286 - ICE with __is_constructible and variadic template.
index af84c257e963a0c7b27bbf27f4ee1610189cc010..5fd3b82fa8937bcf7c6b61c46fc22f3ad651b0a1 100644 (file)
@@ -1496,17 +1496,6 @@ process_init_constructor_array (tree type, tree init, int nested, int flags,
        = massage_init_elt (TREE_TYPE (type), ce->value, nested, flags,
                            complain);
 
-      if (TREE_CODE (ce->value) == CONSTRUCTOR
-         && CONSTRUCTOR_PLACEHOLDER_BOUNDARY (ce->value))
-       {
-         /* Shift CONSTRUCTOR_PLACEHOLDER_BOUNDARY from the element initializer
-            up to the array initializer, so that the call to
-            replace_placeholders from store_init_value can resolve any
-            PLACEHOLDER_EXPRs inside this element initializer.  */
-         CONSTRUCTOR_PLACEHOLDER_BOUNDARY (ce->value) = 0;
-         CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
-       }
-
       gcc_checking_assert
        (ce->value == error_mark_node
         || (same_type_ignoring_top_level_qualifiers_p
@@ -1535,13 +1524,6 @@ process_init_constructor_array (tree type, tree init, int nested, int flags,
              /* The default zero-initialization is fine for us; don't
                 add anything to the CONSTRUCTOR.  */
              next = NULL_TREE;
-           else if (TREE_CODE (next) == CONSTRUCTOR
-                    && CONSTRUCTOR_PLACEHOLDER_BOUNDARY (next))
-             {
-               /* As above.  */
-               CONSTRUCTOR_PLACEHOLDER_BOUNDARY (next) = 0;
-               CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
-             }
          }
        else if (!zero_init_p (TREE_TYPE (type)))
          next = build_zero_init (TREE_TYPE (type),
index 61b2f9e71dbab3a6236cffbe5012e6a2c48e2701..0a77dbdf980c0fa25cb0b6ccd58a4660ca226087 100644 (file)
@@ -1,3 +1,9 @@
+2020-05-15  Patrick Palka  <ppalka@redhat.com>
+
+       PR c++/90996
+       * g++.dg/cpp1y/pr90996.C: Turn into execution test to verify that each
+       PLACEHOLDER_EXPR gets correctly resolved.
+
 2020-05-15  Tobias Burnus  <tobias@codesourcery.com>
 
        PR fortran/94690
index 780cbb4e3ac5623afeb657d8f2896f899de9197b..eff5b62db2892988e9ba990425040f65c7453953 100644 (file)
@@ -1,5 +1,5 @@
 // PR c++/90996
-// { dg-do compile { target c++14 } }
+// { dg-do run { target c++14 } }
 
 struct S
 {
@@ -15,3 +15,20 @@ struct T
 };
 
 T d {};
+
+int
+main()
+{
+  if (++c[0][0].b[0] != 6
+      || ++c[0][1].b[0] != 3
+      || ++c[1][0].b[0] != 3
+      || ++c[1][1].b[0] != 3)
+    __builtin_abort();
+
+  auto& e = d.c;
+  if (++e[0][0].b[0] != 8
+      || ++e[0][1].b[0] != 3
+      || ++e[1][0].b[0] != 3
+      || ++e[1][1].b[0] != 3)
+    __builtin_abort();
+}