On Tue, Dec 12, 2023 at 07:29:40PM +0000, Jason Xu wrote: > Support was recently added for class-level warmth attributes that are > propagated to member functions. The current implementation ignores > member function templates and this patch fixes that.
Thanks for the patch. Is there a bug in the Bugzilla for this? > gcc/cp/ChangeLog: > > * class.cc (propagate_class_warmth_attribute): fix warmth > propagation for member function templates Nit, but s/fix/Fix/, and add a full stop at the end. > --- > gcc/cp/class.cc | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc > index 6fdb56abfb9..68e0f2e9e13 100644 > --- a/gcc/cp/class.cc > +++ b/gcc/cp/class.cc > @@ -7805,8 +7805,13 @@ propagate_class_warmth_attribute (tree t) > > if (class_has_cold_attr || class_has_hot_attr) > for (tree f = TYPE_FIELDS (t); f; f = DECL_CHAIN (f)) > - if (TREE_CODE (f) == FUNCTION_DECL) > -maybe_propagate_warmth_attributes (f, t); > + { > +tree real_f = f; > +if (TREE_CODE (f) == TEMPLATE_DECL) > + real_f = DECL_TEMPLATE_RESULT (f); > +if (TREE_CODE (real_f) == FUNCTION_DECL) > + maybe_propagate_warmth_attributes (real_f, t); > + } Don't you want just: --- a/gcc/cp/class.cc +++ b/gcc/cp/class.cc @@ -7805,7 +7805,7 @@ propagate_class_warmth_attribute (tree t) if (class_has_cold_attr || class_has_hot_attr) for (tree f = TYPE_FIELDS (t); f; f = DECL_CHAIN (f)) - if (TREE_CODE (f) == FUNCTION_DECL) + if (TREE_CODE (STRIP_TEMPLATE (f)) == FUNCTION_DECL) maybe_propagate_warmth_attributes (f, t); } Also, can you add a test for this? Marek