Commit 0c0d447a by Jason Merrill Committed by Jason Merrill

re PR c++/64989 (constant-initialization of self-referencing array)

	PR c++/64989
	* pt.c (splice_late_return_type): Correct deduced return type for
	abbreviated function template.

From-SVN: r226207
parent 8edd0f66
2015-07-24 Jason Merrill <jason@redhat.com>
PR c++/64989
* pt.c (splice_late_return_type): Correct deduced return type for
abbreviated function template.
2015-07-24 Richard Biener <rguenther@suse.de> 2015-07-24 Richard Biener <rguenther@suse.de>
* init.c (build_vec_init): Build iterator bound in the same * init.c (build_vec_init): Build iterator bound in the same
......
...@@ -22459,15 +22459,19 @@ do_auto_deduction (tree type, tree init, tree auto_node) ...@@ -22459,15 +22459,19 @@ do_auto_deduction (tree type, tree init, tree auto_node)
tree tree
splice_late_return_type (tree type, tree late_return_type) splice_late_return_type (tree type, tree late_return_type)
{ {
tree argvec; if (is_auto (type))
{
if (late_return_type)
return late_return_type;
if (late_return_type == NULL_TREE) tree idx = get_template_parm_index (type);
return type; if (TEMPLATE_PARM_LEVEL (idx) <= processing_template_decl)
argvec = make_tree_vec (1); /* In an abbreviated function template we didn't know we were dealing
TREE_VEC_ELT (argvec, 0) = late_return_type; with a function template when we saw the auto return type, so update
if (current_template_parms) it to have the correct level. */
argvec = add_to_template_args (current_template_args (), argvec); return make_auto_1 (TYPE_IDENTIFIER (type));
return tsubst (type, argvec, tf_warning_or_error, NULL_TREE); }
return type;
} }
/* Returns true iff TYPE is a TEMPLATE_TYPE_PARM representing 'auto' or /* Returns true iff TYPE is a TEMPLATE_TYPE_PARM representing 'auto' or
......
// PR c++/64969
// { dg-options "-std=c++1z" }
auto f1(auto x) { return *x; }
decltype(auto) f2(auto x) { return *x; }
auto f3(auto x) -> int { return *x; }
int i;
auto r1 = f1(&i);
auto r2 = f2(&i);
auto r3 = f3(&i);
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