Commit a8b98e2f by Richard Biener Committed by Richard Biener

re PR c++/90801 (A recurring hang)

2019-06-13  Richard Biener  <rguenther@suse.de>

	PR c++/90801
	* typeck2.c (split_nonconstant_init_1): Properly count
	num_split_elts, optimize single constructor elt removal.

From-SVN: r272235
parent c29c92c7
2019-06-13 Richard Biener <rguenther@suse.de>
PR c++/90801
* typeck2.c (split_nonconstant_init_1): Properly count
num_split_elts, optimize single constructor elt removal.
2019-06-12 Marek Polacek <polacek@redhat.com> 2019-06-12 Marek Polacek <polacek@redhat.com>
PR c++/66999 - 'this' captured by reference. PR c++/66999 - 'this' captured by reference.
......
...@@ -603,7 +603,7 @@ cxx_incomplete_type_error (location_t loc, const_tree value, const_tree type) ...@@ -603,7 +603,7 @@ cxx_incomplete_type_error (location_t loc, const_tree value, const_tree type)
static bool static bool
split_nonconstant_init_1 (tree dest, tree init) split_nonconstant_init_1 (tree dest, tree init)
{ {
unsigned HOST_WIDE_INT idx, tidx; unsigned HOST_WIDE_INT idx, tidx = HOST_WIDE_INT_M1U;
tree field_index, value; tree field_index, value;
tree type = TREE_TYPE (dest); tree type = TREE_TYPE (dest);
tree inner_type = NULL; tree inner_type = NULL;
...@@ -657,9 +657,13 @@ split_nonconstant_init_1 (tree dest, tree init) ...@@ -657,9 +657,13 @@ split_nonconstant_init_1 (tree dest, tree init)
if (!split_nonconstant_init_1 (sub, value)) if (!split_nonconstant_init_1 (sub, value))
complete_p = false; complete_p = false;
else else
/* Mark element for removal. */ {
CONSTRUCTOR_ELT (init, idx)->index = NULL_TREE; /* Mark element for removal. */
num_split_elts++; CONSTRUCTOR_ELT (init, idx)->index = NULL_TREE;
if (idx < tidx)
tidx = idx;
num_split_elts++;
}
} }
else if (!initializer_constant_valid_p (value, inner_type)) else if (!initializer_constant_valid_p (value, inner_type))
{ {
...@@ -668,6 +672,8 @@ split_nonconstant_init_1 (tree dest, tree init) ...@@ -668,6 +672,8 @@ split_nonconstant_init_1 (tree dest, tree init)
/* Mark element for removal. */ /* Mark element for removal. */
CONSTRUCTOR_ELT (init, idx)->index = NULL_TREE; CONSTRUCTOR_ELT (init, idx)->index = NULL_TREE;
if (idx < tidx)
tidx = idx;
if (TREE_CODE (field_index) == RANGE_EXPR) if (TREE_CODE (field_index) == RANGE_EXPR)
{ {
...@@ -705,17 +711,18 @@ split_nonconstant_init_1 (tree dest, tree init) ...@@ -705,17 +711,18 @@ split_nonconstant_init_1 (tree dest, tree init)
num_split_elts++; num_split_elts++;
} }
} }
if (num_split_elts != 0) if (num_split_elts == 1)
CONSTRUCTOR_ELTS (init)->ordered_remove (tidx);
else if (num_split_elts > 1)
{ {
/* Perform the delayed ordered removal of non-constant elements /* Perform the delayed ordered removal of non-constant elements
we split out. */ we split out. */
for (tidx = 0, idx = 0; idx < CONSTRUCTOR_NELTS (init); ++idx) for (idx = tidx; idx < CONSTRUCTOR_NELTS (init); ++idx)
if (CONSTRUCTOR_ELT (init, idx)->index == NULL_TREE) if (CONSTRUCTOR_ELT (init, idx)->index == NULL_TREE)
; ;
else else
{ {
if (tidx != idx) *CONSTRUCTOR_ELT (init, tidx) = *CONSTRUCTOR_ELT (init, idx);
*CONSTRUCTOR_ELT (init, tidx) = *CONSTRUCTOR_ELT (init, idx);
++tidx; ++tidx;
} }
vec_safe_truncate (CONSTRUCTOR_ELTS (init), tidx); vec_safe_truncate (CONSTRUCTOR_ELTS (init), tidx);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment