Re: [PATCH] c++: Add missing "to" in reflection diagnostic

Marek Polacek <[email protected]> Mon, 3 Aug 2026 09:08:37 -0400
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>
On Sat, Aug 01, 2026 at 02:37:47PM +0800, EienMiku wrote:
> 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.

Thanks, the patch looks good to me, but I can't approve it.
 
> 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]>
> ---
>  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 989d7cebc77..032ecd70fe6 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 e27a23dbd6c..73ca6a5a01f 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:];
>    };
>  }
> -- 
> 2.52.0.windows.1
> 

Marek