From: Marek Polacek Date: Wed, 28 Jan 2026 20:43:35 +0000 (-0500) Subject: c++/reflection: tweak for eval_has_template_arguments X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=397b0827bcd40eb9b0c5c4bfae7a3dcb2030cef2;p=thirdparty%2Fgcc.git c++/reflection: tweak for eval_has_template_arguments As discussed in : > 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 --- diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc index 141294dd2b2..78990ce414d 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 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;