diff -urN gcc-13.1.0-orig/gcc/c/c-decl.cc gcc-13.1.0/gcc/c/c-decl.cc
--- gcc-13.1.0-orig/gcc/c/c-decl.cc	2023-04-26 16:09:39 +0900
+++ gcc-13.1.0/gcc/c/c-decl.cc	2023-05-07 15:46:20 +0900
@@ -3895,8 +3895,9 @@
 	}
       if (!already)
 	{
-          inform (loc, "each undeclared identifier is reported only"
-                  " once for each function it appears in");
+	  inform_with_flags (loc, DI_NO_CARET,
+			     "each undeclared identifier is reported only"
+			     " once for each function it appears in");
 	  already = true;
 	}
 
diff -urN gcc-13.1.0-orig/gcc/c-family/c-opts.cc gcc-13.1.0/gcc/c-family/c-opts.cc
--- gcc-13.1.0-orig/gcc/c-family/c-opts.cc	2023-04-26 16:09:39 +0900
+++ gcc-13.1.0/gcc/c-family/c-opts.cc	2023-05-07 16:03:46 +0900
@@ -169,10 +169,13 @@
   char *saved_prefix = pp_take_prefix (context->printer);
   pp_set_prefix (context->printer, NULL);
   pp_newline (context->printer);
-  diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind);
-  /* By default print macro expansion contexts in the diagnostic
-     finalizer -- for tokens resulting from macro expansion.  */
-  virt_loc_aware_diagnostic_finalizer (context, diagnostic);
+  if (!(diagnostic->flags & DI_NO_CARET))
+    {
+      diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind);
+      /* By default print macro expansion contexts in the diagnostic
+         finalizer -- for tokens resulting from macro expansion.  */
+      virt_loc_aware_diagnostic_finalizer (context, diagnostic);
+    }
   pp_set_prefix (context->printer, saved_prefix);
   pp_flush (context->printer);
 }
diff -urN gcc-13.1.0-orig/gcc/cp/call.cc gcc-13.1.0/gcc/cp/call.cc
--- gcc-13.1.0-orig/gcc/cp/call.cc	2023-04-26 16:09:39 +0900
+++ gcc-13.1.0/gcc/cp/call.cc	2023-05-07 15:45:59 +0900
@@ -3901,34 +3901,41 @@
     fn = strip_inheriting_ctors (fn);
   location_t cloc = location_of (fn);
 
+  diagnostic_info_flags diagnostic_flags = 
+    (candidate->reason != NULL && candidate->reason->code != rr_none)
+    ? DI_NO_CARET : 0;
+
   if (identifier_p (fn))
     {
       cloc = loc;
       if (candidate->num_convs == 3)
-	inform (cloc, "%s%<%D(%T, %T, %T)%> (built-in)", msg, fn,
+	inform_with_flags (cloc, diagnostic_flags,
+		"%s%<%D(%T, %T, %T)%> (built-in)", msg, fn,
 		candidate->convs[0]->type,
 		candidate->convs[1]->type,
 		candidate->convs[2]->type);
       else if (candidate->num_convs == 2)
-	inform (cloc, "%s%<%D(%T, %T)%> (built-in)", msg, fn,
+	inform_with_flags (cloc, diagnostic_flags,
+		"%s%<%D(%T, %T)%> (built-in)", msg, fn,
 		candidate->convs[0]->type,
 		candidate->convs[1]->type);
       else
-	inform (cloc, "%s%<%D(%T)%> (built-in)", msg, fn,
+	inform_with_flags (cloc, diagnostic_flags,
+		"%s%<%D(%T)%> (built-in)", msg, fn,
 		candidate->convs[0]->type);
     }
   else if (TYPE_P (fn))
-    inform (cloc, "%s%qT (conversion)", msg, fn);
+    inform_with_flags (cloc, diagnostic_flags, "%s%qT (conversion)", msg, fn);
   else if (candidate->viable == -1)
-    inform (cloc, "%s%#qD (near match)", msg, fn);
+    inform_with_flags (cloc, diagnostic_flags, "%s%#qD (near match)", msg, fn);
   else if (DECL_DELETED_FN (fn))
-    inform (cloc, "%s%#qD (deleted)", msg, fn);
+    inform_with_flags (cloc, diagnostic_flags, "%s%#qD (deleted)", msg, fn);
   else if (candidate->reversed ())
-    inform (cloc, "%s%#qD (reversed)", msg, fn);
+    inform_with_flags (cloc, diagnostic_flags, "%s%#qD (reversed)", msg, fn);
   else if (candidate->rewritten ())
-    inform (cloc, "%s%#qD (rewritten)", msg, fn);
+    inform_with_flags (cloc, diagnostic_flags, "%s%#qD (rewritten)", msg, fn);
   else
-    inform (cloc, "%s%#qD", msg, fn);
+    inform_with_flags (cloc, diagnostic_flags, "%s%#qD", msg, fn);
   if (fn != candidate->fn)
     {
       cloc = location_of (candidate->fn);
diff -urN gcc-13.1.0-orig/gcc/diagnostic-core.h gcc-13.1.0/gcc/diagnostic-core.h
--- gcc-13.1.0-orig/gcc/diagnostic-core.h	2023-04-26 16:09:40 +0900
+++ gcc-13.1.0/gcc/diagnostic-core.h	2023-05-07 15:56:10 +0900
@@ -52,6 +52,13 @@
 
 extern const char *trim_filename (const char *);
 
+typedef unsigned int diagnostic_info_flags;
+enum
+{
+  /* Hide caret information for this diagnostic.  */
+  DI_NO_CARET  = 1 << 0,
+};
+
 /* If we haven't already defined a front-end-specific diagnostics
    style, use the generic one.  */
 #ifndef GCC_DIAG_STYLE
@@ -106,6 +113,8 @@
 extern void sorry_at (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
 extern void inform (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
 extern void inform (rich_location *, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
+extern void inform_with_flags (location_t, diagnostic_info_flags, const char *, ...) 
+  ATTRIBUTE_GCC_DIAG(3,4);
 extern void inform_n (location_t, unsigned HOST_WIDE_INT, const char *,
 		      const char *, ...)
     ATTRIBUTE_GCC_DIAG(3,5) ATTRIBUTE_GCC_DIAG(4,5);
diff -urN gcc-13.1.0-orig/gcc/diagnostic.cc gcc-13.1.0/gcc/diagnostic.cc
--- gcc-13.1.0-orig/gcc/diagnostic.cc	2023-04-26 16:09:40 +0900
+++ gcc-13.1.0/gcc/diagnostic.cc	2023-05-07 15:55:56 +0900
@@ -366,6 +366,7 @@
   diagnostic->metadata = NULL;
   diagnostic->kind = kind;
   diagnostic->option_index = 0;
+  diagnostic->flags = 0;
 }
 
 /* Initialize DIAGNOSTIC, where the message GMSGID has not yet been
@@ -1027,7 +1028,8 @@
   char *saved_prefix = pp_take_prefix (context->printer);
   pp_set_prefix (context->printer, NULL);
   pp_newline (context->printer);
-  diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind);
+  if (!(diagnostic->flags & DI_NO_CARET))
+    diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind);
   pp_set_prefix (context->printer, saved_prefix);
   pp_flush (context->printer);
 }
@@ -1736,7 +1738,7 @@
    and internal_error_no_backtrace, as documented and defined below.  */
 static bool
 diagnostic_impl (rich_location *richloc, const diagnostic_metadata *metadata,
-		 int opt, const char *gmsgid,
+		 int opt, diagnostic_info_flags flags, const char *gmsgid,
 		 va_list *ap, diagnostic_t kind)
 {
   diagnostic_info diagnostic;
@@ -1753,6 +1755,7 @@
 	diagnostic.option_index = opt;
     }
   diagnostic.metadata = metadata;
+  diagnostic.flags = flags;
   return diagnostic_report_diagnostic (global_dc, &diagnostic);
 }
 
@@ -1760,7 +1763,8 @@
    defined below.  */
 static bool
 diagnostic_n_impl (rich_location *richloc, const diagnostic_metadata *metadata,
-		   int opt, unsigned HOST_WIDE_INT n,
+		   int opt, diagnostic_info_flags flags,
+		   unsigned HOST_WIDE_INT n,
 		   const char *singular_gmsgid,
 		   const char *plural_gmsgid,
 		   va_list *ap, diagnostic_t kind)
@@ -1781,6 +1785,7 @@
   if (kind == DK_WARNING)
     diagnostic.option_index = opt;
   diagnostic.metadata = metadata;
+  diagnostic.flags = flags;
   return diagnostic_report_diagnostic (global_dc, &diagnostic);
 }
 
@@ -1794,7 +1799,7 @@
   va_list ap;
   va_start (ap, gmsgid);
   rich_location richloc (line_table, location);
-  bool ret = diagnostic_impl (&richloc, NULL, opt, gmsgid, &ap, kind);
+  bool ret = diagnostic_impl (&richloc, NULL, opt, 0, gmsgid, &ap, kind);
   va_end (ap);
   return ret;
 }
@@ -1808,7 +1813,7 @@
   auto_diagnostic_group d;
   va_list ap;
   va_start (ap, gmsgid);
-  bool ret = diagnostic_impl (richloc, NULL, opt, gmsgid, &ap, kind);
+  bool ret = diagnostic_impl (richloc, NULL, opt, 0, gmsgid, &ap, kind);
   va_end (ap);
   return ret;
 }
@@ -1820,7 +1825,7 @@
 			const char *gmsgid, va_list *ap)
 {
   rich_location richloc (line_table, location);
-  return diagnostic_impl (&richloc, NULL, opt, gmsgid, ap, kind);
+  return diagnostic_impl (&richloc, NULL, opt, 0, gmsgid, ap, kind);
 }
 
 /* An informative note at LOCATION.  Use this for additional details on an error
@@ -1832,7 +1837,7 @@
   va_list ap;
   va_start (ap, gmsgid);
   rich_location richloc (line_table, location);
-  diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_NOTE);
+  diagnostic_impl (&richloc, NULL, -1, 0, gmsgid, &ap, DK_NOTE);
   va_end (ap);
 }
 
@@ -1845,7 +1850,21 @@
   auto_diagnostic_group d;
   va_list ap;
   va_start (ap, gmsgid);
-  diagnostic_impl (richloc, NULL, -1, gmsgid, &ap, DK_NOTE);
+  diagnostic_impl (richloc, NULL, -1, 0, gmsgid, &ap, DK_NOTE);
+  va_end (ap);
+}
+
+/* An informative note at LOCATION.  Use this for additional details on an error
+   message.  This variant accepts diagnostic_info_flags.  */
+void
+inform_with_flags (location_t location, diagnostic_info_flags flags,
+		   const char *gmsgid, ...)
+{
+  auto_diagnostic_group d;
+  va_list ap;
+  va_start (ap, gmsgid);
+  rich_location richloc (line_table, location);
+  diagnostic_impl (&richloc, NULL, -1, flags, gmsgid, &ap, DK_NOTE);
   va_end (ap);
 }
 
@@ -1859,7 +1878,7 @@
   va_start (ap, plural_gmsgid);
   auto_diagnostic_group d;
   rich_location richloc (line_table, location);
-  diagnostic_n_impl (&richloc, NULL, -1, n, singular_gmsgid, plural_gmsgid,
+  diagnostic_n_impl (&richloc, NULL, -1, 0, n, singular_gmsgid, plural_gmsgid,
 		     &ap, DK_NOTE);
   va_end (ap);
 }
@@ -1874,7 +1893,7 @@
   va_list ap;
   va_start (ap, gmsgid);
   rich_location richloc (line_table, input_location);
-  bool ret = diagnostic_impl (&richloc, NULL, opt, gmsgid, &ap, DK_WARNING);
+  bool ret = diagnostic_impl (&richloc, NULL, opt, 0, gmsgid, &ap, DK_WARNING);
   va_end (ap);
   return ret;
 }
@@ -1890,7 +1909,7 @@
   va_list ap;
   va_start (ap, gmsgid);
   rich_location richloc (line_table, location);
-  bool ret = diagnostic_impl (&richloc, NULL, opt, gmsgid, &ap, DK_WARNING);
+  bool ret = diagnostic_impl (&richloc, NULL, opt, 0, gmsgid, &ap, DK_WARNING);
   va_end (ap);
   return ret;
 }
@@ -1905,7 +1924,7 @@
   auto_diagnostic_group d;
   va_list ap;
   va_start (ap, gmsgid);
-  bool ret = diagnostic_impl (richloc, NULL, opt, gmsgid, &ap, DK_WARNING);
+  bool ret = diagnostic_impl (richloc, NULL, opt, 0, gmsgid, &ap, DK_WARNING);
   va_end (ap);
   return ret;
 }
@@ -1923,7 +1942,7 @@
   va_list ap;
   va_start (ap, gmsgid);
   bool ret
-    = diagnostic_impl (richloc, &metadata, opt, gmsgid, &ap,
+    = diagnostic_impl (richloc, &metadata, opt, 0, gmsgid, &ap,
 		       DK_WARNING);
   va_end (ap);
   return ret;
@@ -1940,7 +1959,7 @@
   auto_diagnostic_group d;
   va_list ap;
   va_start (ap, plural_gmsgid);
-  bool ret = diagnostic_n_impl (richloc, NULL, opt, n,
+  bool ret = diagnostic_n_impl (richloc, NULL, opt, 0, n,
 				singular_gmsgid, plural_gmsgid,
 				&ap, DK_WARNING);
   va_end (ap);
@@ -1959,7 +1978,7 @@
   va_list ap;
   va_start (ap, plural_gmsgid);
   rich_location richloc (line_table, location);
-  bool ret = diagnostic_n_impl (&richloc, NULL, opt, n,
+  bool ret = diagnostic_n_impl (&richloc, NULL, opt, 0, n,
 				singular_gmsgid, plural_gmsgid,
 				&ap, DK_WARNING);
   va_end (ap);
@@ -1986,7 +2005,7 @@
   va_list ap;
   va_start (ap, gmsgid);
   rich_location richloc (line_table, location);
-  bool ret = diagnostic_impl (&richloc, NULL, opt, gmsgid, &ap, DK_PEDWARN);
+  bool ret = diagnostic_impl (&richloc, NULL, opt, 0, gmsgid, &ap, DK_PEDWARN);
   va_end (ap);
   return ret;
 }
@@ -2001,7 +2020,7 @@
   auto_diagnostic_group d;
   va_list ap;
   va_start (ap, gmsgid);
-  bool ret = diagnostic_impl (richloc, NULL, opt, gmsgid, &ap, DK_PEDWARN);
+  bool ret = diagnostic_impl (richloc, NULL, opt, 0, gmsgid, &ap, DK_PEDWARN);
   va_end (ap);
   return ret;
 }
@@ -2020,7 +2039,7 @@
   va_list ap;
   va_start (ap, gmsgid);
   rich_location richloc (line_table, location);
-  bool ret = diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_PERMERROR);
+  bool ret = diagnostic_impl (&richloc, NULL, -1, 0, gmsgid, &ap, DK_PERMERROR);
   va_end (ap);
   return ret;
 }
@@ -2035,7 +2054,7 @@
   auto_diagnostic_group d;
   va_list ap;
   va_start (ap, gmsgid);
-  bool ret = diagnostic_impl (richloc, NULL, -1, gmsgid, &ap, DK_PERMERROR);
+  bool ret = diagnostic_impl (richloc, NULL, -1, 0, gmsgid, &ap, DK_PERMERROR);
   va_end (ap);
   return ret;
 }
@@ -2049,7 +2068,7 @@
   va_list ap;
   va_start (ap, gmsgid);
   rich_location richloc (line_table, input_location);
-  diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_ERROR);
+  diagnostic_impl (&richloc, NULL, -1, 0, gmsgid, &ap, DK_ERROR);
   va_end (ap);
 }
 
@@ -2063,7 +2082,7 @@
   va_list ap;
   va_start (ap, plural_gmsgid);
   rich_location richloc (line_table, location);
-  diagnostic_n_impl (&richloc, NULL, -1, n, singular_gmsgid, plural_gmsgid,
+  diagnostic_n_impl (&richloc, NULL, -1, 0, n, singular_gmsgid, plural_gmsgid,
 		     &ap, DK_ERROR);
   va_end (ap);
 }
@@ -2076,7 +2095,7 @@
   va_list ap;
   va_start (ap, gmsgid);
   rich_location richloc (line_table, loc);
-  diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_ERROR);
+  diagnostic_impl (&richloc, NULL, -1, 0, gmsgid, &ap, DK_ERROR);
   va_end (ap);
 }
 
@@ -2090,7 +2109,7 @@
   auto_diagnostic_group d;
   va_list ap;
   va_start (ap, gmsgid);
-  diagnostic_impl (richloc, NULL, -1, gmsgid, &ap, DK_ERROR);
+  diagnostic_impl (richloc, NULL, -1, 0, gmsgid, &ap, DK_ERROR);
   va_end (ap);
 }
 
@@ -2104,7 +2123,7 @@
   va_list ap;
   va_start (ap, gmsgid);
   rich_location richloc (line_table, input_location);
-  diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_SORRY);
+  diagnostic_impl (&richloc, NULL, -1, 0, gmsgid, &ap, DK_SORRY);
   va_end (ap);
 }
 
@@ -2116,7 +2135,7 @@
   va_list ap;
   va_start (ap, gmsgid);
   rich_location richloc (line_table, loc);
-  diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_SORRY);
+  diagnostic_impl (&richloc, NULL, -1, 0, gmsgid, &ap, DK_SORRY);
   va_end (ap);
 }
 
@@ -2138,7 +2157,7 @@
   va_list ap;
   va_start (ap, gmsgid);
   rich_location richloc (line_table, loc);
-  diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_FATAL);
+  diagnostic_impl (&richloc, NULL, -1, 0, gmsgid, &ap, DK_FATAL);
   va_end (ap);
 
   gcc_unreachable ();
@@ -2153,7 +2172,7 @@
   va_list ap;
   va_start (ap, gmsgid);
   rich_location richloc (line_table, input_location);
-  diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_ICE);
+  diagnostic_impl (&richloc, NULL, -1, 0, gmsgid, &ap, DK_ICE);
   va_end (ap);
 
   gcc_unreachable ();
@@ -2169,7 +2188,7 @@
   va_list ap;
   va_start (ap, gmsgid);
   rich_location richloc (line_table, input_location);
-  diagnostic_impl (&richloc, NULL, -1, gmsgid, &ap, DK_ICE_NOBT);
+  diagnostic_impl (&richloc, NULL, -1, 0, gmsgid, &ap, DK_ICE_NOBT);
   va_end (ap);
 
   gcc_unreachable ();
diff -urN gcc-13.1.0-orig/gcc/diagnostic.h gcc-13.1.0/gcc/diagnostic.h
--- gcc-13.1.0-orig/gcc/diagnostic.h	2023-04-26 16:09:40 +0900
+++ gcc-13.1.0/gcc/diagnostic.h	2023-05-07 15:24:42 +0900
@@ -131,6 +131,8 @@
   diagnostic_t kind;
   /* Which OPT_* directly controls this diagnostic.  */
   int option_index;
+  /* Flags that allow more fine-tuning of diagnostics.  */
+  diagnostic_info_flags flags;
 
   /* Inlining context containing locations for each call site along
      the inlining stack.  */
diff -urN gcc-13.1.0-orig/gcc/fortran/error.cc gcc-13.1.0/gcc/fortran/error.cc
--- gcc-13.1.0-orig/gcc/fortran/error.cc	2023-04-26 16:09:40 +0900
+++ gcc-13.1.0/gcc/fortran/error.cc	2023-05-07 15:54:11 +0900
@@ -1223,6 +1223,7 @@
     : gfc_diagnostic_build_locus_prefix (context, s1, s2);
 
   if (!context->show_caret
+      || (diagnostic->flags & DI_NO_CARET)
       || diagnostic_location (diagnostic, 0) <= BUILTINS_LOCATION
       || diagnostic_location (diagnostic, 0) == context->last_location)
     {
diff -urN gcc-13.1.0-orig/gcc/testsuite/lib/prune.exp gcc-13.1.0/gcc/testsuite/lib/prune.exp
--- gcc-13.1.0-orig/gcc/testsuite/lib/prune.exp	2023-04-26 16:09:42 +0900
+++ gcc-13.1.0/gcc/testsuite/lib/prune.exp	2023-05-07 15:15:02 +0900
@@ -115,6 +115,9 @@
     # Call into multiline.exp to handle any multiline output directives.
     set text [handle-multiline-outputs $text]
 
+    # C++ notes
+    regsub -all "(^|\n)\[^\n\]*note: candidate(s)? (are|is):\[^\n\]*" $text "" text
+
     #send_user "After:$text\n"
 
     return $text
