I noticed that when returning an ambiguous call in a void function, we then uselessly gave another error about returning a non-void expression.
Tested x86_64-pc-linux-gnu, applying to trunk. --- gcc/cp/typeck.c | 2 +- gcc/testsuite/g++.dg/other/return2.C | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/other/return2.C diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 29a2942dcaf..27d97859cb3 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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 index 00000000000..b328fa6b5f7 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/return2.C @@ -0,0 +1,7 @@ +void f(long); +void f(char); + +void g() +{ + return f(42); // { dg-error "ambiguous" } +} // { dg-bogus "void" "" { target *-*-* } .-1 } base-commit: e55fdf0aaa09abf207b37e2e6a52136f3f5b153d -- 2.18.1