+2020-03-12 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/94124
+ * decl.c (reshape_init_array_1): Don't unshare constructor if there
+ aren't any trailing zero elts, otherwise only unshare the first
+ nelts.
+
2020-03-11 Jason Merrill <jason@redhat.com>
PR c++/93907
2020-03-10 Jason Merrill <jason@redhat.com>
- PR c++/93956
+ PR c++/93596
* pt.c (maybe_aggr_guide): Check BRACE_ENCLOSED_INITIALIZER_P.
2020-03-10 Jason Merrill <jason@redhat.com>
overload resolution. E.g., initializing a class from
{{0}} might be invalid while initializing the same class
from {{}} might be valid. */
- if (reuse)
- new_init = unshare_constructor (new_init);
-
- vec_safe_truncate (CONSTRUCTOR_ELTS (new_init), nelts);
+ if (reuse && nelts < CONSTRUCTOR_NELTS (new_init))
+ {
+ vec<constructor_elt, va_gc> *v;
+ vec_alloc (v, nelts);
+ for (unsigned int i = 0; i < nelts; i++)
+ {
+ constructor_elt elt = *CONSTRUCTOR_ELT (new_init, i);
+ if (TREE_CODE (elt.value) == CONSTRUCTOR)
+ elt.value = unshare_constructor (elt.value);
+ v->quick_push (elt);
+ }
+ new_init = build_constructor (TREE_TYPE (new_init), v);
+ }
+ else
+ vec_safe_truncate (CONSTRUCTOR_ELTS (new_init), nelts);
}
return new_init;