* typeck.c (check_return_expr): Avoid redundant error.
authorJason Merrill <jason@redhat.com>
Mon, 4 Nov 2019 22:34:59 +0000 (17:34 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 4 Nov 2019 22:34:59 +0000 (17:34 -0500)
From-SVN: r277798

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/g++.dg/other/return2.C [new file with mode: 0644]

index 42dfc325bfa18689b5f9d4fdae5ddec442735024..7c22a5333390f723522d789154f15be35ab02385 100644 (file)
@@ -1,3 +1,7 @@
+2019-11-04  Jason Merrill  <jason@redhat.com>
+
+       * typeck.c (check_return_expr): Avoid redundant error.
+
 2019-11-02  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * typeck.c (composite_pointer_type): Add a const op_location_t&
index 29a2942dcaf0a6b1c305c2f90a0d886acb838ddc..27d97859cb39f24bb7303c4fcd01a20f4c705926 100644 (file)
@@ -9729,7 +9729,7 @@ check_return_expr (tree retval, bool *no_warning)
           type.  In that case, we have to evaluate the expression for
           its side-effects.  */
        finish_expr_stmt (retval);
-      else
+      else if (retval != error_mark_node)
        permerror (input_location,
                   "return-statement with a value, in function "
                   "returning %qT", valtype);
diff --git a/gcc/testsuite/g++.dg/other/return2.C b/gcc/testsuite/g++.dg/other/return2.C
new file mode 100644 (file)
index 0000000..b328fa6
--- /dev/null
@@ -0,0 +1,7 @@
+void f(long);
+void f(char);
+
+void g()
+{
+  return f(42);                        // { dg-error "ambiguous" }
+}                              // { dg-bogus "void" "" { target *-*-* } .-1 }