aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authorJason Merrill <jason@gcc.gnu.org>2011-03-15 14:27:09 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-03-15 14:27:09 -0400
commit4c66d85a558f15893d846c0d7d5e9885b8cdf842 (patch)
tree37f9886968ac0a2a5f0f68d1dc00396a32a27f3f /gcc/cp/call.c
parent56b67510587aa6aa75884ee45f4ddd9108bde7c3 (diff)
downloadgcc-4c66d85a558f15893d846c0d7d5e9885b8cdf842.zip
gcc-4c66d85a558f15893d846c0d7d5e9885b8cdf842.tar.gz
gcc-4c66d85a558f15893d846c0d7d5e9885b8cdf842.tar.bz2
re PR c++/34758 (Bad diagnostic for circular dependency in constructor default argument)
PR c++/34758 * call.c (convert_default_arg): Use DECL_ORIGIN of fn. Check for recursion first. (push_defarg_context, pop_defarg_context): New. * parser.c (cp_parser_late_parsing_default_args): Use them. * cp-tree.h: Declare them. From-SVN: r171009
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 5953e35..499ed03 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -5746,10 +5746,17 @@ cxx_type_promotes_to (tree type)
}
/* ARG is a default argument expression being passed to a parameter of
- the indicated TYPE, which is a parameter to FN. Do any required
- conversions. Return the converted value. */
+ the indicated TYPE, which is a parameter to FN. PARMNUM is the
+ zero-based argument number. Do any required conversions. Return
+ the converted value. */
static GTY(()) VEC(tree,gc) *default_arg_context;
+void
+push_defarg_context (tree fn)
+{ VEC_safe_push (tree, gc, default_arg_context, fn); }
+void
+pop_defarg_context (void)
+{ VEC_pop (tree, default_arg_context); }
tree
convert_default_arg (tree type, tree arg, tree fn, int parmnum)
@@ -5757,15 +5764,8 @@ convert_default_arg (tree type, tree arg, tree fn, int parmnum)
int i;
tree t;
- /* If the ARG is an unparsed default argument expression, the
- conversion cannot be performed. */
- if (TREE_CODE (arg) == DEFAULT_ARG)
- {
- error ("the default argument for parameter %d of %qD has "
- "not yet been parsed",
- parmnum, fn);
- return error_mark_node;
- }
+ /* See through clones. */
+ fn = DECL_ORIGIN (fn);
/* Detect recursion. */
FOR_EACH_VEC_ELT (tree, default_arg_context, i, t)
@@ -5774,7 +5774,17 @@ convert_default_arg (tree type, tree arg, tree fn, int parmnum)
error ("recursive evaluation of default argument for %q#D", fn);
return error_mark_node;
}
- VEC_safe_push (tree, gc, default_arg_context, fn);
+
+ /* If the ARG is an unparsed default argument expression, the
+ conversion cannot be performed. */
+ if (TREE_CODE (arg) == DEFAULT_ARG)
+ {
+ error ("call to %qD uses the default argument for parameter %P, which "
+ "is not yet defined", fn, parmnum);
+ return error_mark_node;
+ }
+
+ push_defarg_context (fn);
if (fn && DECL_TEMPLATE_INFO (fn))
arg = tsubst_default_argument (fn, type, arg);
@@ -5814,7 +5824,7 @@ convert_default_arg (tree type, tree arg, tree fn, int parmnum)
}
pop_deferring_access_checks();
- VEC_pop (tree, default_arg_context);
+ pop_defarg_context ();
return arg;
}