Fix locations in conversion_null_warnings (PR c++/71302)
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 6 Feb 2019 19:44:52 +0000 (19:44 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Wed, 6 Feb 2019 19:44:52 +0000 (19:44 +0000)
commitaa9dc19314914cb0a59493fa97d34a5881759d0e
tree4f2323d48636952633511cb8d2f183e264b6bea9
parentd0307ff2cd24861bee4bd5b277c62d50ca0dbe20
Fix locations in conversion_null_warnings (PR c++/71302)

PR c++/71302 reports that g++ shows poor locations for
-Wzero-as-null-pointer-constant for pointers in function calls,
using the close parenthesis of the call, rather than showing the
pertinent argument.

This particular case was fixed in GCC 8, but regressed on trunk
in r260973.

This patch fixes the regression, and adds column numbers to the
test cases (where they're correct) to avoid regressing them in the
future.  There are still various places where the locations aren't
correct, but fixing them isn't stage 4 material.

gcc/cp/ChangeLog:
PR c++/71302
* call.c (get_location_for_expr_unwinding_for_system_header): New
function.
(conversion_null_warnings): Use it when getting locations for
EXPR, effectively adding a call to
get_location_for_expr_unwinding_for_system_header for
-Wconversion-null and making use of EXPR_LOCATION for
-Wzero-as-null-pointer-constant.

gcc/testsuite/ChangeLog:
PR c++/71302
* g++.dg/cpp0x/Wzero-as-null-pointer-constant-1.C: Add expected
column numbers to dg-warning directives where they are correct.
* g++.dg/warn/Wzero-as-null-pointer-constant-5.C: Likewise.
* g++.dg/warn/Wzero-as-null-pointer-constant-7.C: Likewise.
* g++.dg/warn/Wzero-as-null-pointer-constant-8.C: New test.

From-SVN: r268589
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/Wzero-as-null-pointer-constant-1.C
gcc/testsuite/g++.dg/warn/Wzero-as-null-pointer-constant-1.C
gcc/testsuite/g++.dg/warn/Wzero-as-null-pointer-constant-5.C
gcc/testsuite/g++.dg/warn/Wzero-as-null-pointer-constant-7.C
gcc/testsuite/g++.dg/warn/Wzero-as-null-pointer-constant-8.C [new file with mode: 0644]