Commit f00b411f by Paolo Carlini Committed by Paolo Carlini

re PR c++/80145 ([c++1y] ICE after failed return type deduction)

/cp
2017-05-10  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/80145
	* decl.c (finish_function): To improve error recovery, change the
	logic for calling apply_deduced_return_type.

/testsuite
2017-05-10  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/80145
	* g++.dg/cpp1y/auto-fn37.C: New.
	* g++.dg/cpp1y/auto-fn38.C: Likewise.

From-SVN: r247828
parent 28fed202
2017-05-10 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/80145
* decl.c (finish_function): To improve error recovery, change the
logic for calling apply_deduced_return_type.
2017-05-09 Jason Merrill <jason@redhat.com>
* class.c (check_bases): Ignore empty bases.
......
......@@ -15562,16 +15562,19 @@ finish_function (int flags)
if (!processing_template_decl && FNDECL_USED_AUTO (fndecl)
&& TREE_TYPE (fntype) == current_function_auto_return_pattern)
{
if (!is_auto (current_function_auto_return_pattern)
&& !current_function_returns_value && !current_function_returns_null)
if (is_auto (current_function_auto_return_pattern))
{
apply_deduced_return_type (fndecl, void_type_node);
fntype = TREE_TYPE (fndecl);
}
else if (!current_function_returns_value
&& !current_function_returns_null)
{
error ("no return statements in function returning %qT",
current_function_auto_return_pattern);
inform (input_location, "only plain %<auto%> return type can be "
"deduced to %<void%>");
}
apply_deduced_return_type (fndecl, void_type_node);
fntype = TREE_TYPE (fndecl);
}
// If this is a concept, check that the definition is reasonable.
......
2017-05-10 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/80145
* g++.dg/cpp1y/auto-fn37.C: New.
* g++.dg/cpp1y/auto-fn38.C: Likewise.
2017-05-09 Michael Meissner <meissner@linux.vnet.ibm.com>
PR target/68163
......
// PR c++/80145
// { dg-do compile { target c++14 } }
auto* foo() { return 0; } // { dg-error "unable to deduce" }
auto* foo();
// PR c++/80145
// { dg-do compile { target c++14 } }
auto* foo() { } // { dg-error "no return statements" }
auto* foo();
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