Don't try to instantiate REFLECT_EXPR_HANDLE of REFLECT_ANNOTATION REFLECT_EXPR.

This commit is contained in:
Jakub Jelinek
2026-01-03 16:18:48 +01:00
committed by Marek Polacek
parent 34e0841e21
commit d08fb83ec6
2 changed files with 21 additions and 0 deletions

View File

@@ -23016,6 +23016,11 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
reflect_kind kind = REFLECT_EXPR_KIND (t);
if (TYPE_P (h) || TREE_CODE (h) == NAMESPACE_DECL)
h = tsubst (h, args, complain, in_decl);
else if (kind == REFLECT_ANNOTATION)
/* annotations_of should be called on reflections of already
instantiated entities and so no need to tsubst the annotation
attribute and we rely on pointer equality of that. */
;
else
{
/* [expr.reflect] The id-expression of a reflect-expression is

View File

@@ -0,0 +1,16 @@
// { dg-do compile { target c++26 } }
// { dg-additional-options "-freflection" }
#include <meta>
struct [[=42]] A {};
template <auto I>
inline auto b = [] (auto &&x) { x.template operator () <I> (); };
int
main ()
{
auto l = [&] <auto> {};
auto w = b <annotations_of (^^A)[0]>;
w (l);
}