]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++/reflection: adjust error message
authorMarek Polacek <polacek@redhat.com>
Fri, 16 Jan 2026 20:50:38 +0000 (15:50 -0500)
committerMarek Polacek <polacek@redhat.com>
Sun, 18 Jan 2026 15:57:31 +0000 (10:57 -0500)
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.

Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/reflect.cc
gcc/testsuite/g++.dg/reflect/expr6.C

index c2cc6948798ab43360693398ecb3a1539ed510e0..c1073c59a99c2c84e0788b496b2995156ea06ccc 100644 (file)
@@ -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
index d7d0574ae88cb8c741f6126299b1f88cc7af8bab..a2c224288dbe9f5074684c6a681829db7b60f49d 100644 (file)
@@ -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_." }
     };
   };
 }