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++/86568] -Wnonnull warnings should highlight the relevant argument not the closing parenthesis
Date: Sun, 28 Jun 2020 20:40:17 +0000	[thread overview]
Message-ID: <bug-86568-4-yeasRfNS0D@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-86568-4@http.gcc.gnu.org/bugzilla/>

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW

--- Comment #7 from Martin Sebor <msebor at gcc dot gnu.org> ---
There's still more work to do to make the argument location available to the
warning code (e.g., when passing the literal 0 or nullptr, or to the middle
end) so I'm going to leave this open, but for the following variant of the test
case in comment #0 GCC now prints the warnings below:

$ cat pr86568.C && gcc -O2 -S -Wall pr86568.C
void f(void*, void*) __attribute__((nonnull(2)));

struct A {
  void f(void*, void*) __attribute__((nonnull(2)));
};

int main()
{
  void * const p = 0;

  f(p, p);
  A().f(p, p);
}
pr86568.C: In function ‘int main()’:
pr86568.C:11:8: warning: argument 2 null where non-null expected [-Wnonnull]
   11 |   f(p, p);
      |        ^
pr86568.C:1:6: note: in a call to function ‘void f(void*, void*)’ declared
‘nonnull’
    1 | void f(void*, void*) __attribute__((nonnull(2)));
      |      ^
pr86568.C:12:9: warning: argument 1 null where non-null expected [-Wnonnull]
   12 |   A().f(p, p);
      |         ^
pr86568.C:4:8: note: in a call to function ‘void A::f(void*, void*)’ declared
‘nonnull’
    4 |   void f(void*, void*) __attribute__((nonnull(2)));
      |        ^

  parent reply	other threads:[~2020-06-28 20:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-86568-4@http.gcc.gnu.org/bugzilla/>
2020-06-03 17:12 ` msebor at gcc dot gnu.org
2020-06-05 19:42 ` msebor at gcc dot gnu.org
2020-06-26  9:03 ` redi at gcc dot gnu.org
2020-06-26  9:04 ` redi at gcc dot gnu.org
2020-06-26 13:33 ` redi at gcc dot gnu.org
2020-06-28 20:25 ` cvs-commit at gcc dot gnu.org
2020-06-28 20:40 ` msebor at gcc dot gnu.org [this message]
2020-06-29 11:51 ` cvs-commit at gcc dot gnu.org
2020-06-29 12:38 ` cvs-commit at gcc dot gnu.org
2020-06-29 12:49 ` cvs-commit at gcc dot gnu.org
2020-07-01 14:33 ` cvs-commit at gcc dot gnu.org
2021-05-04 12:31 ` rguenth at gcc dot gnu.org
2022-01-26 17:13 ` 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-86568-4-yeasRfNS0D@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).