http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60761
--- Comment #8 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- (In reply to Richard Biener from comment #5) > which isn't perfect either. Is there a way for the C++ FE to get at the > original function decl that was cloned? Like with > > Index: gcc/cp/error.c > =================================================================== > --- gcc/cp/error.c (revision 209210) > +++ gcc/cp/error.c (working copy) > @@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. > #include "pointer-set.h" > #include "c-family/c-objc.h" > #include "ubsan.h" > +#include "cgraph.h" > > #include <new> // For placement-new. > > @@ -1145,7 +1146,17 @@ dump_decl (cxx_pretty_printer *pp, tree > > case FUNCTION_DECL: > if (! DECL_LANG_SPECIFIC (t)) > - pp_string (pp, M_("<built-in>")); > + { > + cgraph_node *node; > + if ((node = cgraph_get_node (t)) > + && node->former_clone_of) > + { > + dump_decl (pp, node->former_clone_of, flags); > + pp_string (pp, M_(" <clone>")); > + } > + else > + pp_string (pp, M_("<built-in>")); > + } > else if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t)) > dump_global_iord (pp, t); > else > Wouldn't it be better for the middle end to provide its own diagnostic_starter function, which in turn calls the FE one and override current_function_declaration around the call to the FE one by the original function? This will also allow in the future the middle-end to override other stuff that it doesn't want the FE to deal with.