Commit bfc48cd8 by Nathan Froyd Committed by Nathan Froyd

call.c (add_builtin_candidates): Use VECs for local variable `types'.

	* call.c (add_builtin_candidates): Use VECs for local variable
	`types'.  Adjust remainder of function accordingly.

From-SVN: r163035
parent d4ccba66
2010-08-09 Nathan Froyd <froydnj@codesourcery.com> 2010-08-09 Nathan Froyd <froydnj@codesourcery.com>
* call.c (add_builtin_candidates): Use VECs for local variable
`types'. Adjust remainder of function accordingly.
2010-08-09 Nathan Froyd <froydnj@codesourcery.com>
* name-lookup.c (is_associated_namespace): Convert local variables * name-lookup.c (is_associated_namespace): Convert local variables
to be VECs instead of TREE_LISTs. to be VECs instead of TREE_LISTs.
......
...@@ -2328,12 +2328,11 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code, ...@@ -2328,12 +2328,11 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code,
{ {
int ref1, i; int ref1, i;
int enum_p = 0; int enum_p = 0;
tree type, argtypes[3]; tree type, argtypes[3], t;
/* TYPES[i] is the set of possible builtin-operator parameter types /* TYPES[i] is the set of possible builtin-operator parameter types
we will consider for the Ith argument. These are represented as we will consider for the Ith argument. */
a TREE_LIST; the TREE_VALUE of each node is the potential VEC(tree,gc) *types[2];
parameter type. */ unsigned ix;
tree types[2];
for (i = 0; i < 3; ++i) for (i = 0; i < 3; ++i)
{ {
...@@ -2395,7 +2394,8 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code, ...@@ -2395,7 +2394,8 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code,
ref1 = 0; ref1 = 0;
} }
types[0] = types[1] = NULL_TREE; types[0] = make_tree_vector ();
types[1] = make_tree_vector ();
for (i = 0; i < 2; ++i) for (i = 0; i < 2; ++i)
{ {
...@@ -2414,11 +2414,11 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code, ...@@ -2414,11 +2414,11 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code,
if (code == COND_EXPR) if (code == COND_EXPR)
{ {
if (real_lvalue_p (args[i])) if (real_lvalue_p (args[i]))
types[i] = tree_cons VEC_safe_push (tree, gc, types[i],
(NULL_TREE, build_reference_type (argtypes[i]), types[i]); build_reference_type (argtypes[i]));
types[i] = tree_cons VEC_safe_push (tree, gc, types[i],
(NULL_TREE, TYPE_MAIN_VARIANT (argtypes[i]), types[i]); TYPE_MAIN_VARIANT (argtypes[i]));
} }
else if (! convs) else if (! convs)
...@@ -2434,54 +2434,60 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code, ...@@ -2434,54 +2434,60 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code,
continue; continue;
if (code == COND_EXPR && TREE_CODE (type) == REFERENCE_TYPE) if (code == COND_EXPR && TREE_CODE (type) == REFERENCE_TYPE)
types[i] = tree_cons (NULL_TREE, type, types[i]); VEC_safe_push (tree, gc, types[i], type);
type = non_reference (type); type = non_reference (type);
if (i != 0 || ! ref1) if (i != 0 || ! ref1)
{ {
type = TYPE_MAIN_VARIANT (type_decays_to (type)); type = TYPE_MAIN_VARIANT (type_decays_to (type));
if (enum_p && TREE_CODE (type) == ENUMERAL_TYPE) if (enum_p && TREE_CODE (type) == ENUMERAL_TYPE)
types[i] = tree_cons (NULL_TREE, type, types[i]); VEC_safe_push (tree, gc, types[i], type);
if (INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (type)) if (INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (type))
type = type_promotes_to (type); type = type_promotes_to (type);
} }
if (! value_member (type, types[i])) if (! vec_member (type, types[i]))
types[i] = tree_cons (NULL_TREE, type, types[i]); VEC_safe_push (tree, gc, types[i], type);
} }
} }
else else
{ {
if (code == COND_EXPR && real_lvalue_p (args[i])) if (code == COND_EXPR && real_lvalue_p (args[i]))
types[i] = tree_cons VEC_safe_push (tree, gc, types[i],
(NULL_TREE, build_reference_type (argtypes[i]), types[i]); build_reference_type (argtypes[i]));
type = non_reference (argtypes[i]); type = non_reference (argtypes[i]);
if (i != 0 || ! ref1) if (i != 0 || ! ref1)
{ {
type = TYPE_MAIN_VARIANT (type_decays_to (type)); type = TYPE_MAIN_VARIANT (type_decays_to (type));
if (enum_p && UNSCOPED_ENUM_P (type)) if (enum_p && UNSCOPED_ENUM_P (type))
types[i] = tree_cons (NULL_TREE, type, types[i]); VEC_safe_push (tree, gc, types[i], type);
if (INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (type)) if (INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (type))
type = type_promotes_to (type); type = type_promotes_to (type);
} }
types[i] = tree_cons (NULL_TREE, type, types[i]); VEC_safe_push (tree, gc, types[i], type);
} }
} }
/* Run through the possible parameter types of both arguments, /* Run through the possible parameter types of both arguments,
creating candidates with those parameter types. */ creating candidates with those parameter types. */
for (; types[0]; types[0] = TREE_CHAIN (types[0])) FOR_EACH_VEC_ELT_REVERSE (tree, types[0], ix, t)
{ {
if (types[1]) unsigned jx;
for (type = types[1]; type; type = TREE_CHAIN (type)) tree u;
if (!VEC_empty (tree, types[1]))
FOR_EACH_VEC_ELT_REVERSE (tree, types[1], jx, u)
add_builtin_candidate add_builtin_candidate
(candidates, code, code2, fnname, TREE_VALUE (types[0]), (candidates, code, code2, fnname, t,
TREE_VALUE (type), args, argtypes, flags); u, args, argtypes, flags);
else else
add_builtin_candidate add_builtin_candidate
(candidates, code, code2, fnname, TREE_VALUE (types[0]), (candidates, code, code2, fnname, t,
NULL_TREE, args, argtypes, flags); NULL_TREE, args, argtypes, flags);
} }
release_tree_vector (types[0]);
release_tree_vector (types[1]);
} }
......
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