https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88245

--- Comment #3 from Matthew Beliveau <mbelivea at gcc dot gnu.org> ---
The location for the note message is getting reset in cp/method.c
(synthesize_method), line 894, here:

  if (!DECL_INHERITED_CTOR (fndecl))
    DECL_SOURCE_LOCATION (fndecl)
      = DECL_SOURCE_LOCATION (TYPE_NAME (DECL_CONTEXT (fndecl)));

I found that the fndecl had the right location for the note going into the
function but then it was reset to something that it never was before. So since
we are testing with explicitly defaulted functions, maybe we shouldn't reset
the location? 

A possible fix would be this:

  if (!DECL_INHERITED_CTOR (fndecl) && !DECL_DEFAULTED_FN(fndecl))
    DECL_SOURCE_LOCATION (fndecl)
      = DECL_SOURCE_LOCATION (TYPE_NAME (DECL_CONTEXT (fndecl)));

This would make sure the location for explicitly defaulted functions wouldn't
be reset here, and make the test case work has intended. However, I'm not
entirely sure if this is the appropriate fix

Reply via email to