Currently, if a warning references a cloned function, the name of the cloned function will be emitted in the "In function %qs" part of the diagnostic, which users aren't supposed to see. This patch follows the DECL_ORIGIN link to get the name of the original function.
gcc/ChangeLog: PR diagnostics/102061 * langhooks.cc (lhd_print_error_function): Follow DECL_ORIGIN link Signed-off-by: Peter Damianov <peter0...@disroot.org> --- I struggled to write a testcase for this, as none of the real world cases I tried reduced to anything nice. Hopefully it's okay to skip it at this time. gcc/langhooks.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/langhooks.cc b/gcc/langhooks.cc index 61f2b676256..ab5f0932310 100644 --- a/gcc/langhooks.cc +++ b/gcc/langhooks.cc @@ -395,6 +395,8 @@ lhd_print_error_function (diagnostic_context *context, const char *file, else fndecl = current_function_decl; + fndecl = DECL_ORIGIN(fndecl); + if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE) pp_printf (context->printer, _("In member function %qs"), -- 2.39.2