From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 400C73945C2C; Thu, 8 Apr 2021 16:32:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 400C73945C2C From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/99420] [11 Regression] bogus -Warray-parameter on a function redeclaration in function scope Date: Thu, 08 Apr 2021 16:32:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 16:32:37 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99420 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org, | |jsm28 at gcc dot gnu.org --- Comment #4 from Jakub Jelinek --- If not copying over the attribute is intentional when it isn't builtin, we could still copy over just the single attribute, like: --- gcc/c/c-decl.c.jj 2021-03-16 00:21:29.464233163 +0100 +++ gcc/c/c-decl.c 2021-04-08 18:19:24.762093841 +0200 @@ -3268,6 +3268,17 @@ pushdecl (tree x) thistype =3D build_type_attribute_variant (thistype, TYPE_ATTRIBUTES (b->u.type)); + else if (!lookup_attribute ("access", TYPE_ATTRIBUTES (thistype))) + if (tree access =3D lookup_attribute ("access", + TYPE_ATTRIBUTES (b->u.type)= )) + { + /* Otherwise, copy over the access attribute. */ + tree attr =3D tree_cons (TREE_PURPOSE (access), + TREE_VALUE (access), + TYPE_ATTRIBUTES (thistype)); + thistype + =3D build_type_attribute_variant (thistype, attr); + } TREE_TYPE (b->decl) =3D thistype; bind (name, b->decl, scope, /*invisible=3D*/false, /*nested=3D*/t= rue, locus); Except that the access attribute unfortunately seems to mean a lot of diffe= rent things, it is a user attribute with some arguments that is later rewritten = into a different form and that other form is reused also for the array parameters and the -Warray-parameter stuff using that. So, if both decls of f1 should have different attributes, then doing the ab= ove is undesirable because it would also result in user's access attributes bei= ng copied over, or that for user access attribute on the second declaration wo= uld result in it not being copied. Perhaps we can copy the attribute under a different attribute name (somethi= ng with space in it so that it isn't user accessible) and use that for -Warray-parameter purposes in preference over "access"? Also, I'd argue that the rewritten "access" attribute shouldn't be called "access" but with some internal name.=