[gcc r17-2913] c++: Add missing "to" in reflection diagnostic

Jason Merrill via Gcc-cvs <[email protected]> Mon, 3 Aug 2026 22:04:07 +0000 (GMT)
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:7ca55e0fa867c51e6fd39a8fe1378011471c9e1b

commit r17-2913-g7ca55e0fa867c51e6fd39a8fe1378011471c9e1b
Author: EienMiku <[email protected]>
Date:   Sat Aug 1 14:37:47 2026 +0800

    c++: Add missing "to" in reflection diagnostic
    
    The diagnostic for applying ^^ to a local entity with an intervening
    lambda expression reads "cannot be applied a local entity"; add the
    missing "to", matching the phrasing of the other diagnostics in
    get_reflection.
    
    gcc/cp/ChangeLog:
    
            * reflect.cc (get_reflection): Add missing "to" in diagnostic.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/reflect/expr9.C: Adjust expected diagnostic.
    
    Signed-off-by: EienMiku <[email protected]>

Diff:
---
 gcc/cp/reflect.cc                    | 2 +-
 gcc/testsuite/g++.dg/reflect/expr9.C | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc
index d1cfeeacfa5f..cfb9292849fc 100644
--- a/gcc/cp/reflect.cc
+++ b/gcc/cp/reflect.cc
@@ -179,7 +179,7 @@ get_reflection (location_t loc, tree t, reflect_kind kind/*=REFLECT_UNDEF*/)
 	       || parsing_lambda_declarator ()))
     {
       auto_diagnostic_group d;
-      error_at (loc, "%<^^%> cannot be applied a local entity for which "
+      error_at (loc, "%<^^%> cannot be applied to a local entity for which "
 		"there is an intervening lambda expression");
       inform (DECL_SOURCE_LOCATION (t), "%qD declared here", t);
       return error_mark_node;
diff --git a/gcc/testsuite/g++.dg/reflect/expr9.C b/gcc/testsuite/g++.dg/reflect/expr9.C
index e27a23dbd6ce..73ca6a5a01f7 100644
--- a/gcc/testsuite/g++.dg/reflect/expr9.C
+++ b/gcc/testsuite/g++.dg/reflect/expr9.C
@@ -33,7 +33,7 @@ fn3 ()
   int x = 1;	// { dg-message ".x. declared here" }
 
   [] -> int {
-    static constexpr auto r = ^^x;  // { dg-error "cannot be applied a local entity" }
+    static constexpr auto r = ^^x;  // { dg-error "cannot be applied to a local entity" }
     return [:r:];
   };
 }
@@ -67,7 +67,7 @@ void
 fn6 (int x)   // { dg-message ".x. declared here" }
 {
   [] -> int {
-    static constexpr auto r = ^^x;  // { dg-error "cannot be applied a local entity" }
+    static constexpr auto r = ^^x;  // { dg-error "cannot be applied to a local entity" }
     return [:r:];
   };
 }