https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51344
--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:a0fdff3cf33f72848d3f894272431a5d49fe6a16 commit r12-299-ga0fdff3cf33f72848d3f894272431a5d49fe6a16 Author: Jason Merrill <ja...@redhat.com> Date: Fri Feb 5 10:36:49 2021 -0500 c++: Fix friend attributes [PR51344] 51344 was a problem with calling save_template_attributes twice for the same friend function: once from do_friend and once from grokmethod. The 2012 patch for the bug avoided creating an infinite loop when this happens, but it's better to avoid the duplication in the first place. This also restores the dependent attributes to the beginning of the attribute list, as originally intended. And then apply_late_template_attributes can avoid copying the non-dependent attributes. gcc/cp/ChangeLog: PR c++/51344 * decl2.c (grokfield): Call cplus_decl_attributes for friend. (save_template_attributes): Use chainon. * friend.c (do_friend): Remove attrlist parm. * cp-tree.h (do_friend): Adjust. * class.c (add_implicitly_declared_members): Adjust. * decl.c (grokdeclarator): Adjust. * pt.c (apply_late_template_attributes): Optimize.