Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

-- >8 --
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.
---
 gcc/cp/reflect.cc | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc
index bdeec2f0f38..071f224ff40 100644
--- a/gcc/cp/reflect.cc
+++ b/gcc/cp/reflect.cc
@@ -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;

base-commit: b20e68022a3f49010028dc01dab570c68071e3db
-- 
2.52.0

Reply via email to