On Mon, 30 Mar 2026 at 23:02, Jakub Jelinek <[email protected]> wrote: > > On Mon, Mar 30, 2026 at 03:59:28PM -0400, Jason Merrill wrote: > > > + /* Similarly for these 3 metafns. */ > > > + if (id_equal (DECL_NAME (fn), "current_function") > > > + || id_equal (DECL_NAME (fn), "current_class") > > > + || id_equal (DECL_NAME (fn), "current_namespace")) > > > > Optionally, I wonder about looking up the METAFN_ code rather than a bunch > > of id_equal? > > I wanted to avoid that because right now metafns.h is fairly large header > included in reflect.cc only ATM. And actually it isn't even includable in > multiple TUs, while the gperf generated hash method is inline, the > static find method is not and we can't have multiple definitions thereof. > > > > --- gcc/cp/reflect.cc.jj 2026-03-27 10:17:14.033332387 +0100 > > > +++ gcc/cp/reflect.cc 2026-03-27 15:51:18.122236375 +0100 > > > @@ -6236,11 +6236,11 @@ eval_reflect_constant_array (location_t > > > return get_reflection_raw (loc, decl); > > > } > > > -/* Process std::meta::access_context::current. */ > > > +/* Return CURRENT-SCOPE(P). */ > > > static tree > > > -eval_access_context_current (location_t loc, const constexpr_ctx *ctx, > > > - tree call, bool *non_constant_p) > > > +current_scope (location_t loc, const constexpr_ctx *ctx, tree call, > > > > There's already a current_scope in search.cc, this shouldn't have the same > > name. > > It is static, but changed that to reflect_current_scope. > > > > +/* Process std::meta::current_namespace. */ > > > + > > > +static tree > > > +eval_current_namespace (location_t loc, const constexpr_ctx *ctx, > > > + tree call, bool *non_constant_p) > > > +{ > > > + tree scope = current_scope (loc, ctx, call, non_constant_p, > > > + "std::meta::current_namespace"); > > > + while (TREE_CODE (scope) != NAMESPACE_DECL) > > > + { > > > + if (DECL_P (scope)) > > > + scope = CP_DECL_CONTEXT (scope); > > > + else > > > + scope = CP_TYPE_CONTEXT (scope); > > > + } > > > > decl_namespace_context? > > Changed. > > 2026-03-30 Jakub Jelinek <[email protected]> > > gcc/cp/ > * metafns.gperf (enum metafn_code): Add METAFN_CURRENT_FUNCTION, > METAFN_CURRENT_CLASS and METAFN_CURRENT_NAMESPACE. > (enum metafn_kind): Add METAFN_KIND_INFO_VOID. > (current_function, current_class, current_namespace): New > metafunctions. > * pt.cc (value_dependent_expression_p): Make current_function(), > current_class() and current_namespace() calls dependent if they > are inside of template. > * reflect.cc (reflect_current_scope, eval_current_function, > eval_current_class, eval_current_namespace): New functions. > (eval_access_context_current): Use reflect_current_scope. > (process_metafunction): Handle METAFN_CURRENT_FUNCTION, > METAFN_CURRENT_CLASS and METAFN_CURRENT_NAMESPACE. > * metafns.h: Regenerate. > gcc/testsuite/ > * g++.dg/reflect/current_function1.C: New test. > * g++.dg/reflect/current_function2.C: New test. > * g++.dg/reflect/current_class1.C: New test. > * g++.dg/reflect/current_class2.C: New test. > * g++.dg/reflect/current_namespace1.C: New test. > libstdc++-v3/ > * include/std/meta (std::meta::current_function, > std::meta::current_class, std::meta::current_namespace): New > declarations. > * src/c++23/std.cc.in: Export those 3.
The library parts are OK.
