aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2017-05-10 08:34:02 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2017-05-10 08:34:02 +0000
commitf00b411f5437114d7ee7107be1d150b7d893dfc7 (patch)
tree1b95a2649f2744301ace45d27e808db0a87b5c52
parent28fed2026a5b4c5750af7f1d51055ebfae46fede (diff)
downloadgcc-f00b411f5437114d7ee7107be1d150b7d893dfc7.zip
gcc-f00b411f5437114d7ee7107be1d150b7d893dfc7.tar.gz
gcc-f00b411f5437114d7ee7107be1d150b7d893dfc7.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c11
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/auto-fn37.C5
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/auto-fn38.C5
5 files changed, 29 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7c63318..ddc571f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+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.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 74cf018..a5f62fe 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index adec236..8ec71d7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn37.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn37.C
new file mode 100644
index 0000000..3f664b4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn37.C
@@ -0,0 +1,5 @@
+// PR c++/80145
+// { dg-do compile { target c++14 } }
+
+auto* foo() { return 0; } // { dg-error "unable to deduce" }
+auto* foo();
diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn38.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn38.C
new file mode 100644
index 0000000..ec3cffb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn38.C
@@ -0,0 +1,5 @@
+// PR c++/80145
+// { dg-do compile { target c++14 } }
+
+auto* foo() { } // { dg-error "no return statements" }
+auto* foo();