diff -urN gcc-14.1.0-orig/gcc/c/c-decl.cc gcc-14.1.0/gcc/c/c-decl.cc
--- gcc-14.1.0-orig/gcc/c/c-decl.cc	2024-05-07 15:51:37 +0900
+++ gcc-14.1.0/gcc/c/c-decl.cc	2024-07-18 02:15:44 +0900
@@ -4002,8 +4002,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-14.1.0-orig/gcc/c-family/c-opts.cc gcc-14.1.0/gcc/c-family/c-opts.cc
--- gcc-14.1.0-orig/gcc/c-family/c-opts.cc	2024-05-07 15:51:37 +0900
+++ gcc-14.1.0/gcc/c-family/c-opts.cc	2024-07-18 02:15:44 +0900
@@ -174,10 +174,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-14.1.0-orig/gcc/cp/call.cc gcc-14.1.0/gcc/cp/call.cc
--- gcc-14.1.0-orig/gcc/cp/call.cc	2024-05-07 15:51:37 +0900
+++ gcc-14.1.0/gcc/cp/call.cc	2024-07-18 02:15:44 +0900
@@ -3953,36 +3953,43 @@
     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 (ignored_candidate_p (candidate))
-    inform (cloc, "%s%#qD (ignored)", msg, fn);
+    inform_with_flags (cloc, diagnostic_flags, "%s%#qD (ignored)", 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-14.1.0-orig/gcc/diagnostic-core.h gcc-14.1.0/gcc/diagnostic-core.h
--- gcc-14.1.0-orig/gcc/diagnostic-core.h	2024-05-07 15:51:37 +0900
+++ gcc-14.1.0/gcc/diagnostic-core.h	2024-07-18 02:15:44 +0900
@@ -55,6 +55,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
@@ -116,6 +123,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-14.1.0-orig/gcc/diagnostic.cc gcc-14.1.0/gcc/diagnostic.cc
--- gcc-14.1.0-orig/gcc/diagnostic.cc	2024-05-07 15:51:37 +0900
+++ gcc-14.1.0/gcc/diagnostic.cc	2024-07-18 02:17:58 +0900
@@ -465,6 +465,7 @@
   diagnostic->metadata = NULL;
   diagnostic->kind = kind;
   diagnostic->option_index = 0;
+  diagnostic->flags = 0;
 }
 
 /* Initialize DIAGNOSTIC, where the message GMSGID has not yet been
@@ -1101,7 +1102,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);
 }
@@ -1753,7 +1755,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;
@@ -1771,6 +1773,7 @@
 	diagnostic.option_index = opt;
     }
   diagnostic.metadata = metadata;
+  diagnostic.flags = flags;
   return global_dc->report_diagnostic (&diagnostic);
 }
 
@@ -1778,7 +1781,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)
@@ -1799,6 +1803,7 @@
   if (kind == DK_WARNING)
     diagnostic.option_index = opt;
   diagnostic.metadata = metadata;
+  diagnostic.flags = flags;
   return global_dc->report_diagnostic (&diagnostic);
 }
 
@@ -1812,7 +1817,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;
 }
@@ -1826,7 +1831,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;
 }
@@ -1838,7 +1843,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);
 }
 
 /* As above, but with rich_location and metadata.  */
@@ -1850,7 +1855,7 @@
 			     int opt,
 			     const char *gmsgid, va_list *ap)
 {
-  return diagnostic_impl (richloc, metadata, opt, gmsgid, ap, kind);
+  return diagnostic_impl (richloc, metadata, opt, 0, gmsgid, ap, kind);
 }
 
 /* An informative note at LOCATION.  Use this for additional details on an error
@@ -1862,7 +1867,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);
 }
 
@@ -1875,7 +1880,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);
 }
 
@@ -1889,7 +1908,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);
 }
@@ -1904,7 +1923,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;
 }
@@ -1920,7 +1939,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;
 }
@@ -1935,7 +1954,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;
 }
@@ -1953,7 +1972,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;
@@ -1970,7 +1989,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);
@@ -1989,7 +2008,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);
@@ -2016,7 +2035,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;
 }
@@ -2031,7 +2050,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;
 }
@@ -2050,7 +2069,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;
 }
@@ -2065,7 +2084,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;
 }
@@ -2081,7 +2100,7 @@
   va_list ap;
   va_start (ap, gmsgid);
   rich_location richloc (line_table, location);
-  bool ret = diagnostic_impl (&richloc, NULL, opt, gmsgid, &ap, DK_PERMERROR);
+  bool ret = diagnostic_impl (&richloc, NULL, opt, 0, gmsgid, &ap, DK_PERMERROR);
   va_end (ap);
   return ret;
 }
@@ -2096,7 +2115,7 @@
   auto_diagnostic_group d;
   va_list ap;
   va_start (ap, gmsgid);
-  bool ret = diagnostic_impl (richloc, NULL, opt, gmsgid, &ap, DK_PERMERROR);
+  bool ret = diagnostic_impl (richloc, NULL, opt, 0, gmsgid, &ap, DK_PERMERROR);
   va_end (ap);
   return ret;
 }
@@ -2110,7 +2129,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);
 }
 
@@ -2124,7 +2143,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);
 }
@@ -2137,7 +2156,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);
 }
 
@@ -2151,7 +2170,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);
 }
 
@@ -2166,7 +2185,7 @@
   auto_diagnostic_group d;
   va_list ap;
   va_start (ap, gmsgid);
-  diagnostic_impl (richloc, &metadata, -1, gmsgid, &ap, DK_ERROR);
+  diagnostic_impl (richloc, &metadata, -1, 0, gmsgid, &ap, DK_ERROR);
   va_end (ap);
 }
 
@@ -2180,7 +2199,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);
 }
 
@@ -2192,7 +2211,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);
 }
 
@@ -2214,7 +2233,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 ();
@@ -2229,7 +2248,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 ();
@@ -2245,7 +2264,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-14.1.0-orig/gcc/diagnostic.h gcc-14.1.0/gcc/diagnostic.h
--- gcc-14.1.0-orig/gcc/diagnostic.h	2024-05-07 15:51:37 +0900
+++ gcc-14.1.0/gcc/diagnostic.h	2024-07-18 02:15:44 +0900
@@ -155,6 +155,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-14.1.0-orig/gcc/fortran/error.cc gcc-14.1.0/gcc/fortran/error.cc
--- gcc-14.1.0-orig/gcc/fortran/error.cc	2024-05-07 15:51:37 +0900
+++ gcc-14.1.0/gcc/fortran/error.cc	2024-07-18 02:15:44 +0900
@@ -1286,6 +1286,7 @@
     : gfc_diagnostic_build_locus_prefix (context, s1, s2);
 
   if (!context->m_source_printing.enabled
+      || (diagnostic->flags & DI_NO_CARET)
       || diagnostic_location (diagnostic, 0) <= BUILTINS_LOCATION
       || diagnostic_location (diagnostic, 0) == context->m_last_location)
     {
diff -urN gcc-14.1.0-orig/gcc/testsuite/lib/prune.exp gcc-14.1.0/gcc/testsuite/lib/prune.exp
--- gcc-14.1.0-orig/gcc/testsuite/lib/prune.exp	2024-05-07 15:51:40 +0900
+++ gcc-14.1.0/gcc/testsuite/lib/prune.exp	2024-07-18 02:15:44 +0900
@@ -109,6 +109,9 @@
     # Many tests that use visibility will still pass on platforms that don't support it.
     regsub -all "(^|\n)\[^\n\]*lto1: warning: visibility attribute not supported in this configuration; ignored\[^\n\]*" $text "" text
 
+    # C++ notes
+    regsub -all "(^|\n)\[^\n\]*note: candidate(s)? (are|is):\[^\n\]*" $text "" text
+
     #send_user "After:$text\n"
 
     return $text
