From: Marek Polacek Date: Tue, 14 Apr 2026 14:13:11 +0000 (-0400) Subject: c++: introduce reflection_function_template_p X-Git-Tag: basepoints/gcc-17~194 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bf2349b8b7e69d2be217a53cc32dc833885aebd;p=thirdparty%2Fgcc.git c++: introduce reflection_function_template_p As discussed in , this patch introduces a new predicate to be used instead of really_overloaded_fn when we're checking for a function template in the Reflection code. gcc/cp/ChangeLog: * cp-tree.h (reflection_function_template_p): Declare. * parser.cc (cp_parser_splice_expression): Use reflection_function_template_p instead of really_overloaded_fn. * reflect.cc (check_splice_expr): Likewise. (reflection_function_template_p): New. Reviewed-by: Jason Merrill --- diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 1080203ac8a..c5a3a6bd39b 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -9442,6 +9442,7 @@ extern tree make_splice_scope (tree, bool); extern bool dependent_splice_p (const_tree) ATTRIBUTE_PURE; extern tree reflection_mangle_prefix (tree, char [3]); extern void check_consteval_only_fn (tree); +extern bool reflection_function_template_p (tree) ATTRIBUTE_PURE; /* Inline bodies. */ diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 9dbc2933e7b..742cfd03621 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -6341,7 +6341,7 @@ cp_parser_splice_expression (cp_parser *parser, bool template_p, && (targs_p /* No 'template' but the splice-specifier designates a function template? */ - || really_overloaded_fn (t)) + || reflection_function_template_p (t)) && warning_enabled_at (loc, OPT_Wmissing_template_keyword)) /* Were 'template' present, this would be valid code, so keep going. */ missing_template_diag (loc, diagnostics::kind::pedwarn); diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc index 4ef340f0726..2bbab5e183b 100644 --- a/gcc/cp/reflect.cc +++ b/gcc/cp/reflect.cc @@ -8978,7 +8978,7 @@ check_splice_expr (location_t loc, location_t start_loc, tree t, template. */ if (!targs_p) { - if (!really_overloaded_fn (t) && !dependent_splice_p (t)) + if (!reflection_function_template_p (t) && !dependent_splice_p (t)) { if (complain_p) { @@ -9005,7 +9005,7 @@ check_splice_expr (location_t loc, location_t start_loc, tree t, } return false; } - gcc_checking_assert (really_overloaded_fn (t) + gcc_checking_assert (reflection_function_template_p (t) || get_template_info (t) || TREE_CODE (t) == TEMPLATE_ID_EXPR || variable_template_p (t) @@ -9197,4 +9197,12 @@ reflection_mangle_prefix (tree refl, char prefix[3]) gcc_unreachable (); } +/* Returns true iff X is a reflection of a function template. */ + +bool +reflection_function_template_p (tree x) +{ + return really_overloaded_fn (x); +} + #include "gt-cp-reflect.h"