public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-99420-4-AfqW2rjgjS@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99420-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99420

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jsm28 at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
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
              = build_type_attribute_variant (thistype,
                                              TYPE_ATTRIBUTES (b->u.type));
+         else if (!lookup_attribute ("access", TYPE_ATTRIBUTES (thistype)))
+           if (tree access = lookup_attribute ("access",
+                                               TYPE_ATTRIBUTES (b->u.type)))
+             {
+               /* Otherwise, copy over the access attribute.  */
+               tree attr = tree_cons (TREE_PURPOSE (access),
+                                      TREE_VALUE (access),
+                                      TYPE_ATTRIBUTES (thistype));
+               thistype
+                 = build_type_attribute_variant (thistype, attr);
+             }
          TREE_TYPE (b->decl) = thistype;
          bind (name, b->decl, scope, /*invisible=*/false, /*nested=*/true,
                locus);
Except that the access attribute unfortunately seems to mean a lot of different
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 above
is undesirable because it would also result in user's access attributes being
copied over, or that for user access attribute on the second declaration would
result in it not being copied.
Perhaps we can copy the attribute under a different attribute name (something
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.

  parent reply	other threads:[~2021-04-08 16:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-05 20:06 [Bug c/99420] New: New warning -Warray-parameter raj.khem at gmail dot com
2021-03-07  0:19 ` [Bug c/99420] " egallager at gcc dot gnu.org
2021-03-08  9:25 ` marxin at gcc dot gnu.org
2021-03-08 17:34 ` msebor at gcc dot gnu.org
2021-03-16 11:52 ` [Bug c/99420] [11 Regression] bogus -Warray-parameter on a function redeclaration in function scope rguenth at gcc dot gnu.org
2021-04-08 12:56 ` rguenth at gcc dot gnu.org
2021-04-08 16:32 ` jakub at gcc dot gnu.org [this message]
2021-04-08 16:48 ` msebor at gcc dot gnu.org
2021-04-08 22:17 ` msebor at gcc dot gnu.org
2021-04-15 21:51 ` cvs-commit at gcc dot gnu.org
2021-04-15 21:52 ` msebor at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-99420-4-AfqW2rjgjS@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).