On 8/5/23 5:53 PM, David Malcolm wrote:
...but the warning branch uses "warning", which implicitly uses the
input_location global variable. Is the warning reported at the correct
place? It's better to use warning_at and pass it the location at which
the warning should be emitted.
Thanks, I changed the patch to follow your suggestion.
I built and ran make check with the patch; there were no changes to the
test results.
As a test, I again built GCC with
../../gcc-mainline/configure CXX="/pkgs/gcc-mainline-new-new/bin/g++
-Wdisabled-optimization" --enable-languages=c --disable-multilib
--prefix=/pkgs/gcc-mainline-test-test --disable-werror --disable-bootstrap
I found no changes to the warning messages.
Brad
diff --git a/gcc/calls.cc b/gcc/calls.cc
index 1f3a6d5c450..de293ac51bb 100644
--- a/gcc/calls.cc
+++ b/gcc/calls.cc
@@ -1242,10 +1242,12 @@ void
maybe_complain_about_tail_call (tree call_expr, const char *reason)
{
gcc_assert (TREE_CODE (call_expr) == CALL_EXPR);
- if (!CALL_EXPR_MUST_TAIL_CALL (call_expr))
- return;
-
- error_at (EXPR_LOCATION (call_expr), "cannot tail-call: %s", reason);
+ if (CALL_EXPR_MUST_TAIL_CALL (call_expr))
+ error_at (EXPR_LOCATION (call_expr), "cannot tail-call: %s", reason);
+ else if (flag_optimize_sibling_calls)
+ warning_at (EXPR_LOCATION (call_expr), OPT_Wdisabled_optimization,
+ "cannot apply sibling-call optimization: %s", reason);
+ return;
}
/* Fill in ARGS_SIZE and ARGS array based on the parameters found in