]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++/reflection: tweak for eval_has_template_arguments
authorMarek Polacek <polacek@redhat.com>
Wed, 28 Jan 2026 20:43:35 +0000 (15:43 -0500)
committerMarek Polacek <polacek@redhat.com>
Thu, 29 Jan 2026 13:45:20 +0000 (08:45 -0500)
As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705756.html>:

> For reflection it's probably best to go with
>
> if (TYPE_P (r) && typedef_variant_p (r))
>   return alias_template_specialization_p (r, nt_opaque);
>
> and not get into primary_template_specialization_p at all.

Here in a patch form.

gcc/cp/ChangeLog:

* reflect.cc (eval_has_template_arguments): Return immediately after
checking alias_template_specialization_p.

Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/reflect.cc

index 141294dd2b2c5c669474e9c8d697e54a550d6b31..78990ce414d23d99d16b6546db87abf0f5c77773 100644 (file)
@@ -2805,13 +2805,12 @@ static tree
 eval_has_template_arguments (tree r)
 {
   r = MAYBE_BASELINK_FUNCTIONS (r);
-  /* Presumably for
+  /* For
        typedef cls_tmpl<int> TYPE;
-     'has_template_arguments (^^TYPE)' should be false?  */
-  if (TYPE_P (r)
-      && typedef_variant_p (r)
-      && !alias_template_specialization_p (r, nt_opaque))
-    return boolean_false_node;
+     'has_template_arguments (^^TYPE)' should be false.  */
+  if (TYPE_P (r) && typedef_variant_p (r))
+    return (alias_template_specialization_p (r, nt_opaque)
+           ? boolean_true_node : boolean_false_node);
   if (primary_template_specialization_p (r)
       || variable_template_specialization_p (r))
     return boolean_true_node;