public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/99420] New warning -Warray-parameter
Date: Mon, 08 Mar 2021 17:34:58 +0000	[thread overview]
Message-ID: <bug-99420-4-VBjznsnHQQ@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

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
The false positive is caused by the local redeclaration of f1() in h() below
not having had the type attributes added to it describing the form of the
array.  This happens because instead of merging the type attributes from the
previous declaration of f1() in g() into those in h() as is done for f0,
pushdecl() sets them to null (on lines 3525-3562 in c/c-decl.c).   The
difference is due to pushdecl() treating redeclarations of entities that are in
scope (like f0) differently than those that aren't (like f1() in h()).

$ cat u.c && gcc -S -Wall u.c
void f0 (int [1]);
void f0 (int [1]);   // okay

void g (void)
{
  void f1 (int [1]);
}

void h (void)
{
  void f1 (int [1]);   // bogus -Warray-parameter
}

u.c: In function ‘h’:
u.c:11:12: warning: argument 1 of type ‘int[1]’ with mismatched bound
[-Warray-parameter=]
   11 |   void f1 (int [1]);   // bogus -Warray-parameter
      |            ^~~~~~~
u.c:6:12: note: previously declared as ‘int *’
    6 |   void f1 (int [1]);
      |            ^~~~~~~

  parent reply	other threads:[~2021-03-08 17:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-05 20:06 [Bug c/99420] New: " 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 [this message]
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
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-VBjznsnHQQ@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).