Commit 8c8b42cf by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/71446 (Incorrect overload resolution when using designated initializers)

	PR c++/71446
	* call.c (filed_in_pset): Change pset from hash_set<tree> * to
	hash_set<tree, true> &, adjust uses accordingly.
	(build_aggr_conv): Change pset from hash_set<tree> *
	to hash_set<tree, true>.  Replace goto fail; with return NULL;,
	adjust pset uses.

From-SVN: r269861
parent 152d47df
2019-03-21 Jakub Jelinek <jakub@redhat.com> 2019-03-21 Jakub Jelinek <jakub@redhat.com>
PR c++/71446
* call.c (filed_in_pset): Change pset from hash_set<tree> * to
hash_set<tree, true> &, adjust uses accordingly.
(build_aggr_conv): Change pset from hash_set<tree> *
to hash_set<tree, true>. Replace goto fail; with return NULL;,
adjust pset uses.
PR c++/89767 PR c++/89767
* parser.c (cp_parser_lambda_introducer): Add ids and first_capture_id * parser.c (cp_parser_lambda_introducer): Add ids and first_capture_id
variables, check for duplicates in this function. variables, check for duplicates in this function.
......
...@@ -907,9 +907,9 @@ can_convert_array (tree atype, tree ctor, int flags, tsubst_flags_t complain) ...@@ -907,9 +907,9 @@ can_convert_array (tree atype, tree ctor, int flags, tsubst_flags_t complain)
is in PSET. */ is in PSET. */
static bool static bool
field_in_pset (hash_set<tree> *pset, tree field) field_in_pset (hash_set<tree, true> &pset, tree field)
{ {
if (pset->contains (field)) if (pset.contains (field))
return true; return true;
if (ANON_AGGR_TYPE_P (TREE_TYPE (field))) if (ANON_AGGR_TYPE_P (TREE_TYPE (field)))
for (field = TYPE_FIELDS (TREE_TYPE (field)); for (field = TYPE_FIELDS (TREE_TYPE (field));
...@@ -934,7 +934,7 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain) ...@@ -934,7 +934,7 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain)
conversion *c; conversion *c;
tree field = next_initializable_field (TYPE_FIELDS (type)); tree field = next_initializable_field (TYPE_FIELDS (type));
tree empty_ctor = NULL_TREE; tree empty_ctor = NULL_TREE;
hash_set<tree> *pset = NULL; hash_set<tree, true> pset;
/* We already called reshape_init in implicit_conversion. */ /* We already called reshape_init in implicit_conversion. */
...@@ -964,7 +964,7 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain) ...@@ -964,7 +964,7 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain)
complain); complain);
if (!ok) if (!ok)
goto fail; return NULL;
/* For unions, there should be just one initializer. */ /* For unions, there should be just one initializer. */
if (TREE_CODE (type) == UNION_TYPE) if (TREE_CODE (type) == UNION_TYPE)
{ {
...@@ -972,12 +972,10 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain) ...@@ -972,12 +972,10 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain)
i = 1; i = 1;
break; break;
} }
if (pset == NULL) pset.add (idx);
pset = new hash_set<tree>;
pset->add (idx);
} }
else else
goto fail; return NULL;
} }
} }
...@@ -987,7 +985,7 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain) ...@@ -987,7 +985,7 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain)
tree val; tree val;
bool ok; bool ok;
if (pset && field_in_pset (pset, field)) if (pset.elements () && field_in_pset (pset, field))
continue; continue;
if (i < CONSTRUCTOR_NELTS (ctor)) if (i < CONSTRUCTOR_NELTS (ctor))
{ {
...@@ -998,7 +996,7 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain) ...@@ -998,7 +996,7 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain)
val = get_nsdmi (field, /*ctor*/false, complain); val = get_nsdmi (field, /*ctor*/false, complain);
else if (TYPE_REF_P (ftype)) else if (TYPE_REF_P (ftype))
/* Value-initialization of reference is ill-formed. */ /* Value-initialization of reference is ill-formed. */
goto fail; return NULL;
else else
{ {
if (empty_ctor == NULL_TREE) if (empty_ctor == NULL_TREE)
...@@ -1014,22 +1012,15 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain) ...@@ -1014,22 +1012,15 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain)
complain); complain);
if (!ok) if (!ok)
goto fail; return NULL;
if (TREE_CODE (type) == UNION_TYPE) if (TREE_CODE (type) == UNION_TYPE)
break; break;
} }
if (i < CONSTRUCTOR_NELTS (ctor)) if (i < CONSTRUCTOR_NELTS (ctor))
{ return NULL;
fail:
if (pset)
delete pset;
return NULL;
}
if (pset)
delete pset;
c = alloc_conversion (ck_aggr); c = alloc_conversion (ck_aggr);
c->type = type; c->type = type;
c->rank = cr_exact; c->rank = cr_exact;
......
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