From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8647D3851C09; Sun, 28 Jun 2020 20:40:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8647D3851C09 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1593376817; bh=wGUhfvnOBYMgBhl2rC3nHb9Q8MmUzbdjgCYjI6q+zNc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WaIyxuWjHWpYA/JBoSppbjuTtrlqmLtdsLF1jNY6YCuQzhAeLfO4Cf6AN4mwdE+2p WHQa8iw/5MxrQ+zmrbemWY7Pdj5psrD07HsZJuTL0bJzjFQIqertR4uxeQYyG9v1r1 XO73FbXDEcJNpTAjPS781Eil3cTwrcObOsvI2X+o= From: "msebor at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 9.0 X-Bugzilla-Keywords: diagnostic, patch X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: msebor at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status 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: Sun, 28 Jun 2020 20:40:17 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D86568 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |NEW --- Comment #7 from Martin Sebor --- 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 =3D 0; f(p, p); A().f(p, p); } pr86568.C: In function =E2=80=98int main()=E2=80=99: 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 =E2=80=98void f(void*, void*)=E2= =80=99 declared =E2=80=98nonnull=E2=80=99 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 =E2=80=98void A::f(void*, void*)= =E2=80=99 declared =E2=80=98nonnull=E2=80=99 4 | void f(void*, void*) __attribute__((nonnull(2))); | ^=