2018-04-10 Jason Merrill <jason@redhat.com>
+ PR debug/65821 - wrong location for main().
+ * call.c (clear_location_r): New.
+ (convert_default_arg): Use it.
+ * tree.c (bot_manip): Remove builtin_LINE/FILE handling.
+
PR c++/85285 - ICE with flexible array after substitution.
* pt.c (instantiate_class_template_1): Check for flexible array in
union.
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
/* 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 = convert_for_initialization (0, type, arg, LOOKUP_IMPLICIT,
ICR_DEFAULT_ARGUMENT, fn, parmnum,
complain);
/* Make a copy of this node. */
t = copy_tree_r (tp, walk_subtrees, NULL);
if (TREE_CODE (*tp) == CALL_EXPR)
- {
- set_flags_from_callee (*tp);
-
- /* builtin_LINE and builtin_FILE get the location where the default
- argument is expanded, not where the call was written. */
- tree callee = get_callee_fndecl (*tp);
- if (callee && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL)
- switch (DECL_FUNCTION_CODE (callee))
- {
- case BUILT_IN_FILE:
- case BUILT_IN_LINE:
- SET_EXPR_LOCATION (*tp, input_location);
- default:
- break;
- }
- }
+ set_flags_from_callee (*tp);
return t;
}