+2016-03-23 Patrick Palka <ppalka@gcc.gnu.org>
+
+ PR c++/70347
+ * typeck.c (process_init_constructor_union): If the initializer
+ is empty, use the union's NSDMI if it has one.
+
2016-03-23 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/70332
constructor_elt *ce;
int len;
- /* If the initializer was empty, use default zero initialization. */
+ /* If the initializer was empty, use the union's NSDMI if it has one.
+ Otherwise use default zero initialization. */
if (vec_safe_is_empty (CONSTRUCTOR_ELTS (init)))
- return 0;
+ {
+ for (tree field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
+ {
+ if (DECL_INITIAL (field))
+ {
+ CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (init),
+ field,
+ get_nsdmi (field, /*in_ctor=*/false));
+ break;
+ }
+ }
+
+ if (vec_safe_is_empty (CONSTRUCTOR_ELTS (init)))
+ return 0;
+ }
len = CONSTRUCTOR_ELTS (init)->length ();
if (len > 1)