C and C++ FE: fix source ranges for binary ops
authorDavid Malcolm <dmalcolm@redhat.com>
Mon, 21 Dec 2015 17:45:34 +0000 (17:45 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Mon, 21 Dec 2015 17:45:34 +0000 (17:45 +0000)
commit745e411d4fd4739118356662329a509a8b7d4ae8
tree646f3ed78c4f1afbdbb1c0deb9b8436571b732c3
parent7c154ecc12c064ba3b154d1d27be6f19dbd0c294
C and C++ FE: fix source ranges for binary ops

gcc/c-family/ChangeLog:
* c-common.c (binary_op_error): Convert first param from
location_t to rich_location * and use it when emitting an error.
* c-common.h (binary_op_error): Convert first param from
location_t to rich_location *.

gcc/c/ChangeLog:
* c-typeck.c: Include "gcc-rich-location.h".
(build_binary_op): In the two places that call binary_op_error,
create a gcc_rich_location and populate it with the location of
the binary op and its two operands.

gcc/cp/ChangeLog:
* typeck.c (cp_build_binary_op): Update for change in signature
of build_binary_op.  Use error_at to replace an implicit use
of input_location with param "location" in "invalid operands"
error.
(cp_build_binary_op): Replace an error with an error_at, using
"location", rather than implicitly using input_location.

gcc/testsuite/ChangeLog:
* g++.dg/diagnostic/bad-binary-ops.C: New test case.
* gcc.dg/bad-binary-ops.c: New test case.
gcc.dg/plugin/diagnostic_plugin_show_trees.c (get_range_for_expr):
Remove material copied from gcc-rich-location.c
(gcc_rich_location::add_expr): Likewise.

From-SVN: r231884
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c-common.h
gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/diagnostic/bad-binary-ops.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/bad-binary-ops.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c