return promote;
}
-/* walk_tree callback to override EXPR_LOCATION in an expression tree. */
-
-tree
-clear_location_r (tree *tp, int *walk_subtrees, void */*data*/)
-{
- if (!EXPR_P (*tp))
- {
- *walk_subtrees = 0;
- return NULL_TREE;
- }
- if (EXPR_HAS_LOCATION (*tp))
- SET_EXPR_LOCATION (*tp, input_location);
- return NULL_TREE;
-}
-
/* ARG is a default argument expression being passed to a parameter of
the indicated TYPE, which is a parameter to FN. PARMNUM is the
zero-based argument number. Do any required conversions. Return
push_deferring_access_checks (dk_no_check);
/* We must make a copy of ARG, in case subsequent processing
alters any part of it. */
- arg = break_out_target_exprs (arg);
-
- /* The use of a default argument has the location of the call, not where it
- was originally written. */
- cp_walk_tree_without_duplicates (&arg, clear_location_r, NULL);
+ arg = break_out_target_exprs (arg, /*clear location*/true);
arg = convert_for_initialization (0, type, arg, LOOKUP_IMPLICIT,
ICR_DEFAULT_ARGUMENT, fn, parmnum,
return sz;
}
+struct bot_data
+{
+ splay_tree target_remap;
+ bool clear_location;
+};
+
/* Called from break_out_target_exprs via mapcar. */
static tree
-bot_manip (tree* tp, int* walk_subtrees, void* data)
+bot_manip (tree* tp, int* walk_subtrees, void* data_)
{
- splay_tree target_remap = ((splay_tree) data);
+ bot_data &data = *(bot_data*)data_;
+ splay_tree target_remap = data.target_remap;
tree t = *tp;
if (!TYPE_P (t) && TREE_CONSTANT (t) && !TREE_SIDE_EFFECTS (t))
(splay_tree_key) TREE_OPERAND (t, 0),
(splay_tree_value) TREE_OPERAND (u, 0));
- TREE_OPERAND (u, 1) = break_out_target_exprs (TREE_OPERAND (u, 1));
+ TREE_OPERAND (u, 1) = break_out_target_exprs (TREE_OPERAND (u, 1),
+ data.clear_location);
if (TREE_OPERAND (u, 1) == error_mark_node)
return error_mark_node;
t = copy_tree_r (tp, walk_subtrees, NULL);
if (TREE_CODE (*tp) == CALL_EXPR)
set_flags_from_callee (*tp);
+ if (data.clear_location && EXPR_HAS_LOCATION (*tp))
+ SET_EXPR_LOCATION (*tp, input_location);
return t;
}
variables. */
static tree
-bot_replace (tree* t, int* /*walk_subtrees*/, void* data)
+bot_replace (tree* t, int* /*walk_subtrees*/, void* data_)
{
- splay_tree target_remap = ((splay_tree) data);
+ bot_data &data = *(bot_data*)data_;
+ splay_tree target_remap = data.target_remap;
if (VAR_P (*t))
{
/* When we parse a default argument expression, we may create
temporary variables via TARGET_EXPRs. When we actually use the
default-argument expression, we make a copy of the expression
- and replace the temporaries with appropriate local versions. */
+ and replace the temporaries with appropriate local versions.
+
+ If CLEAR_LOCATION is true, override any EXPR_LOCATION with
+ input_location. */
tree
-break_out_target_exprs (tree t)
+break_out_target_exprs (tree t, bool clear_location /* = false */)
{
static int target_remap_count;
static splay_tree target_remap;
target_remap = splay_tree_new (splay_tree_compare_pointers,
/*splay_tree_delete_key_fn=*/NULL,
/*splay_tree_delete_value_fn=*/NULL);
- if (cp_walk_tree (&t, bot_manip, target_remap, NULL) == error_mark_node)
+ bot_data data = { target_remap, clear_location };
+ if (cp_walk_tree (&t, bot_manip, &data, NULL) == error_mark_node)
t = error_mark_node;
- cp_walk_tree (&t, bot_replace, target_remap, NULL);
+ cp_walk_tree (&t, bot_replace, &data, NULL);
if (!--target_remap_count)
{