diff options
author | David Malcolm <dmalcolm@redhat.com> | 2015-12-21 17:45:34 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2015-12-21 17:45:34 +0000 |
commit | 745e411d4fd4739118356662329a509a8b7d4ae8 (patch) | |
tree | 646f3ed78c4f1afbdbb1c0deb9b8436571b732c3 /gcc/cp | |
parent | 7c154ecc12c064ba3b154d1d27be6f19dbd0c294 (diff) | |
download | gcc-745e411d4fd4739118356662329a509a8b7d4ae8.tar.gz |
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
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 13 |
2 files changed, 19 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1dd533efa79..bba3973a095 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2015-12-21 David Malcolm <dmalcolm@redhat.com> + + * 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. + 2015-12-20 Jason Merrill <jason@redhat.com> PR c++/67411 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index a06ecf0732a..25e74e90193 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4908,7 +4908,13 @@ cp_build_binary_op (location_t location, || !vector_types_compatible_elements_p (type0, type1)) { if (complain & tf_error) - binary_op_error (location, code, type0, type1); + { + /* "location" already embeds the locations of the + operands, so we don't need to add them separately + to richloc. */ + rich_location richloc (line_table, location); + binary_op_error (&richloc, code, type0, type1); + } return error_mark_node; } arithmetic_types_p = 1; @@ -4931,8 +4937,9 @@ cp_build_binary_op (location_t location, if (!result_type) { if (complain & tf_error) - error ("invalid operands of types %qT and %qT to binary %qO", - TREE_TYPE (orig_op0), TREE_TYPE (orig_op1), code); + error_at (location, + "invalid operands of types %qT and %qT to binary %qO", + TREE_TYPE (orig_op0), TREE_TYPE (orig_op1), code); return error_mark_node; } |