]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: apply friend attributes sooner
authorJason Merrill <jason@redhat.com>
Fri, 28 Oct 2022 14:45:06 +0000 (10:45 -0400)
committerJason Merrill <jason@redhat.com>
Fri, 28 Oct 2022 15:15:35 +0000 (11:15 -0400)
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.

gcc/cp/decl.cc

index bc085f8fcce4c0c25640f195d21568c6d524bf0b..c7f1937ea48f3748c9be65c3335b693fc5547903 100644 (file)
@@ -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;