Commit 6781e2af by Jason Merrill Committed by Jason Merrill

PR c++/69223 - ICE with deduced template return type.

	* semantics.c (apply_deduced_return_type): Call
	complete_type_or_else before building the new RESULT_DECL.

From-SVN: r238624
parent 94ced5b4
2016-07-21 Jason Merrill <jason@redhat.com>
PR c++/69223
* semantics.c (apply_deduced_return_type): Call
complete_type_or_else before building the new RESULT_DECL.
PR c++/71274
* decl2.c (maybe_instantiate_decl): Split out from mark_used.
(decl_constant_var_p): Use it instead.
......
......@@ -9279,6 +9279,10 @@ apply_deduced_return_type (tree fco, tree return_type)
if (TREE_TYPE (result) == return_type)
return;
if (!processing_template_decl && !VOID_TYPE_P (return_type)
&& !complete_type_or_else (return_type, NULL_TREE))
return;
/* We already have a DECL_RESULT from start_preparsed_function.
Now we need to redo the work it and allocate_struct_function
did to reflect the new type. */
......@@ -9294,8 +9298,6 @@ apply_deduced_return_type (tree fco, tree return_type)
if (!processing_template_decl)
{
if (!VOID_TYPE_P (TREE_TYPE (result)))
complete_type_or_else (TREE_TYPE (result), NULL_TREE);
bool aggr = aggregate_value_p (result, fco);
#ifdef PCC_STATIC_STRUCT_RETURN
cfun->returns_pcc_struct = aggr;
......
// PR c++/69223
// { dg-do compile { target c++11 } }
template <class T> struct A
{
T x[20];
};
int main()
{
auto l = [](const A<int>& i){ return i; };
A<int> a;
l(a);
}
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