[gcc r16-7142] c++/reflection: tweak for eval_has_template_arguments
Marek Polacek
mpolacek@gcc.gnu.org
Thu Jan 29 13:45:38 GMT 2026
https://gcc.gnu.org/g:397b0827bcd40eb9b0c5c4bfae7a3dcb2030cef2
commit r16-7142-g397b0827bcd40eb9b0c5c4bfae7a3dcb2030cef2
Author: Marek Polacek <polacek@redhat.com>
Date: Wed Jan 28 15:43:35 2026 -0500
c++/reflection: tweak for eval_has_template_arguments
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>
Diff:
---
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 141294dd2b2c..78990ce414d2 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;
More information about the Gcc-cvs
mailing list