]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/cp/typeck2.c
c++: Fix up CONSTRUCTOR_PLACEHOLDER_BOUNDARY handling [PR105256]
[thirdparty/gcc.git] / gcc / cp / typeck2.c
index a7ef373fe08c65667496962334aac7e3080a4ba2..e7e85337d769be2b7d4dfd4681be06c7e7be54a2 100644 (file)
@@ -1438,6 +1438,14 @@ process_init_constructor_array (tree type, tree init, int nested, int flags,
              strip_array_types (TREE_TYPE (ce->value)))));
 
       picflags |= picflag_from_initializer (ce->value);
+      /* Propagate CONSTRUCTOR_PLACEHOLDER_BOUNDARY to outer
+        CONSTRUCTOR.  */
+      if (TREE_CODE (ce->value) == CONSTRUCTOR
+         && CONSTRUCTOR_PLACEHOLDER_BOUNDARY (ce->value))
+       {
+         CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
+         CONSTRUCTOR_PLACEHOLDER_BOUNDARY (ce->value) = 0;
+       }
     }
 
   /* No more initializers. If the array is unbounded, we are done. Otherwise,
@@ -1472,6 +1480,14 @@ process_init_constructor_array (tree type, tree init, int nested, int flags,
        if (next)
          {
            picflags |= picflag_from_initializer (next);
+           /* Propagate CONSTRUCTOR_PLACEHOLDER_BOUNDARY to outer
+              CONSTRUCTOR.  */
+           if (TREE_CODE (next) == CONSTRUCTOR
+               && CONSTRUCTOR_PLACEHOLDER_BOUNDARY (next))
+             {
+               CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
+               CONSTRUCTOR_PLACEHOLDER_BOUNDARY (next) = 0;
+             }
            if (len > i+1
                && (initializer_constant_valid_p (next, TREE_TYPE (next))
                    == null_pointer_node))
@@ -1678,6 +1694,13 @@ process_init_constructor_record (tree type, tree init, int nested, int flags,
       if (type != TREE_TYPE (field))
        next = cp_convert_and_check (TREE_TYPE (field), next, complain);
       picflags |= picflag_from_initializer (next);
+      /* Propagate CONSTRUCTOR_PLACEHOLDER_BOUNDARY to outer CONSTRUCTOR.  */
+      if (TREE_CODE (next) == CONSTRUCTOR
+         && CONSTRUCTOR_PLACEHOLDER_BOUNDARY (next))
+       {
+         CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
+         CONSTRUCTOR_PLACEHOLDER_BOUNDARY (next) = 0;
+       }
       CONSTRUCTOR_APPEND_ELT (v, field, next);
     }
 
@@ -1831,6 +1854,14 @@ process_init_constructor_union (tree type, tree init, int nested, int flags,
     ce->value = massage_init_elt (TREE_TYPE (ce->index), ce->value, nested,
                                  flags, complain);
 
+  /* Propagate CONSTRUCTOR_PLACEHOLDER_BOUNDARY to outer CONSTRUCTOR.  */
+  if (ce->value
+      && TREE_CODE (ce->value) == CONSTRUCTOR
+      && CONSTRUCTOR_PLACEHOLDER_BOUNDARY (ce->value))
+    {
+      CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
+      CONSTRUCTOR_PLACEHOLDER_BOUNDARY (ce->value) = 0;
+    }
   return picflag_from_initializer (ce->value);
 }