aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-04-10 10:24:00 -0400
committerJason Merrill <jason@gcc.gnu.org>2018-04-10 10:24:00 -0400
commit6e2446b6df8e0838e824b14d81fc161bd87f2351 (patch)
treea818b1dcf483ed1a8e9abfad5e1f2cf895f4d2a0 /gcc/cp/call.c
parent05c602a135224b1fbc573fc54e3c925196503187 (diff)
downloadgcc-6e2446b6df8e0838e824b14d81fc161bd87f2351.zip
gcc-6e2446b6df8e0838e824b14d81fc161bd87f2351.tar.gz
gcc-6e2446b6df8e0838e824b14d81fc161bd87f2351.tar.bz2
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. From-SVN: r259278
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index f978ea7..94226d6 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -7296,6 +7296,21 @@ cxx_type_promotes_to (tree type)
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
@@ -7360,6 +7375,11 @@ convert_default_arg (tree type, tree arg, tree fn, int parmnum,
/* 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);