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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Maybe just

--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -3312,12 +3312,19 @@ print_instantiation_full_context (diagnostic_context
*context)

   if (p)
     {
-      pp_verbatim (context->printer,
-          TREE_CODE (p->decl) == TREE_LIST
-          ? _("%s: In substitution of %qS:\n")
-          : _("%s: In instantiation of %q#D:\n"),
-          LOCATION_FILE (location),
-          p->decl);
+      if (location != UNKNOWN_LOCATION)
+   pp_verbatim (context->printer,
+            TREE_CODE (p->decl) == TREE_LIST
+            ? _("%s: In substitution of %qS:\n")
+            : _("%s: In instantiation of %q#D:\n"),
+            LOCATION_FILE (location),
+            p->decl);
+      else
+   pp_verbatim (context->printer,
+            TREE_CODE (p->decl) == TREE_LIST
+            ? _("In substitution of %qS:\n")
+            : _("In instantiation of %q#D:\n"),
+            p->decl);

       location = p->locus;
       p = p->next;

getting a proper location might be much harder.

Reply via email to