aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2015-12-21 17:45:34 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2015-12-21 17:45:34 +0000
commit745e411d4fd4739118356662329a509a8b7d4ae8 (patch)
tree646f3ed78c4f1afbdbb1c0deb9b8436571b732c3 /gcc/c
parent7c154ecc12c064ba3b154d1d27be6f19dbd0c294 (diff)
downloadgcc-745e411d4fd4739118356662329a509a8b7d4ae8.zip
gcc-745e411d4fd4739118356662329a509a8b7d4ae8.tar.gz
gcc-745e411d4fd4739118356662329a509a8b7d4ae8.tar.bz2
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/c')
-rw-r--r--gcc/c/ChangeLog7
-rw-r--r--gcc/c/c-typeck.c11
2 files changed, 16 insertions, 2 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 7c1247d..fb9fda3 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,10 @@
+2015-12-21 David Malcolm <dmalcolm@redhat.com>
+
+ * 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.
+
2015-12-16 David Malcolm <dmalcolm@redhat.com>
* c-parser.c (c_parser_statement_after_labels): When calling
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index b605f81..a97774f 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see
#include "cilk.h"
#include "gomp-constants.h"
#include "spellcheck.h"
+#include "gcc-rich-location.h"
/* Possible cases of implicit bad conversions. Used to select
diagnostic messages in convert_for_assignment. */
@@ -11202,7 +11203,10 @@ build_binary_op (location_t location, enum tree_code code,
&& (!tree_int_cst_equal (TYPE_SIZE (type0), TYPE_SIZE (type1))
|| !vector_types_compatible_elements_p (type0, type1)))
{
- binary_op_error (location, code, type0, type1);
+ gcc_rich_location richloc (location);
+ richloc.maybe_add_expr (orig_op0);
+ richloc.maybe_add_expr (orig_op1);
+ binary_op_error (&richloc, code, type0, type1);
return error_mark_node;
}
@@ -11441,7 +11445,10 @@ build_binary_op (location_t location, enum tree_code code,
if (!result_type)
{
- binary_op_error (location, code, TREE_TYPE (op0), TREE_TYPE (op1));
+ gcc_rich_location richloc (location);
+ richloc.maybe_add_expr (orig_op0);
+ richloc.maybe_add_expr (orig_op1);
+ binary_op_error (&richloc, code, TREE_TYPE (op0), TREE_TYPE (op1));
return error_mark_node;
}