On 1/17/26 8:48 AM, Marek Polacek wrote:
Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

OK.

-- >8 --
Now that the condition includes all captures, let's not talk about
init-capture.  Also print the decl.

gcc/cp/ChangeLog:

        * reflect.cc (get_reflection): Adjust the error message for the
        is_capture_proxy check.

gcc/testsuite/ChangeLog:

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

diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc
index 237f630d71b..6371104c7fd 100644
--- a/gcc/cp/reflect.cc
+++ b/gcc/cp/reflect.cc
@@ -147,8 +147,7 @@ get_reflection (location_t loc, tree t, reflect_kind 
kind/*=REFLECT_UNDEF*/)
       R is ill-formed.  */
    else if (is_capture_proxy (t))
      {
-      error_at (loc, "%<^^%> cannot be applied to a local entity declared "
-               "by init-capture");
+      error_at (loc, "%<^^%> cannot be applied to a capture %qD", t);
        return error_mark_node;
      }
    /* If the id-expression denotes a local parameter introduced by
diff --git a/gcc/testsuite/g++.dg/reflect/expr6.C 
b/gcc/testsuite/g++.dg/reflect/expr6.C
index d7d0574ae88..a2c224288db 100644
--- a/gcc/testsuite/g++.dg/reflect/expr6.C
+++ b/gcc/testsuite/g++.dg/reflect/expr6.C
@@ -39,11 +39,11 @@ h ()
    int y = 42;
    [x_=x, y]() {
      constexpr auto r1 = ^^x;  // { dg-error "intervening lambda expression" }
-    constexpr auto r2 = ^^x_; // { dg-error "local entity declared by 
init-capture" }
+    constexpr auto r2 = ^^x_; // { dg-error "cannot be applied to a capture 
.x_." }
      constexpr auto r3 = ^^y;  // { dg-error "intervening lambda expression" }
[x_]() {
-      constexpr auto r4 = ^^x_;        // { dg-error "local entity declared by 
init-capture" }
+      constexpr auto r4 = ^^x_;        // { dg-error "cannot be applied to a 
capture .x_." }
      };
    };
  }

base-commit: e6532f870a741f15082122eaa1120c72569fe6cf

Reply via email to