From: Jason Merrill Date: Fri, 28 Oct 2022 14:45:06 +0000 (-0400) Subject: c++: apply friend attributes sooner X-Git-Tag: basepoints/gcc-14~3657 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=38a628f52cf0ff5db6708578248484d50a50b366;p=thirdparty%2Fgcc.git c++: apply friend attributes sooner Comparing attributes between declarations of a friend function has been complicated by pushdecl happening before decl_attributes. I assumed there was some complicated reason we weren't calling decl_attributes here, but it doesn't break anything. gcc/cp/ChangeLog: * decl.cc (grokdeclarator): Call decl_attributes before do_friend. --- diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index bc085f8fcce4..c7f1937ea48f 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -14206,13 +14206,16 @@ grokdeclarator (const cp_declarator *declarator, else if (decl && DECL_NAME (decl)) { set_originating_module (decl, true); - + if (initialized) /* Kludge: We need funcdef_flag to be true in do_friend for in-class defaulted functions, but that breaks grokfndecl. So set it here. */ funcdef_flag = true; + cplus_decl_attributes (&decl, *attrlist, 0); + *attrlist = NULL_TREE; + decl = do_friend (ctype, unqualified_id, decl, flags, funcdef_flag); return decl;