]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: introduce reflection_function_template_p
authorMarek Polacek <polacek@redhat.com>
Tue, 14 Apr 2026 14:13:11 +0000 (10:13 -0400)
committerMarek Polacek <polacek@redhat.com>
Tue, 14 Apr 2026 17:53:50 +0000 (13:53 -0400)
As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-April/712156.html>,
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 <jason@redhat.com>
gcc/cp/cp-tree.h
gcc/cp/parser.cc
gcc/cp/reflect.cc

index 1080203ac8a4225978244c4490c20ef9b166a643..c5a3a6bd39be828889b0f3740122b3d0f22b577d 100644 (file)
@@ -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.  */
 
index 9dbc2933e7b5c9dfbd17ccb8d6e58f6775391100..742cfd036218229ae491993e1b9a68273c7c788e 100644 (file)
@@ -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);
index 4ef340f0726cebb6114c79e4eee66ffaec3eef9d..2bbab5e183b837a53cad819f2811d8213790aab4 100644 (file)
@@ -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"