+2016-01-06 David Malcolm <dmalcolm@redhat.com>
+
+ * c-parser.c (c_parser_unary_expression): For dereferences, build
+ a combined location before calling build_indirect_ref, so that
+ error reports cover the full range, manually updating the c_expr
+ src_range.
+
2016-01-06 Marek Polacek <polacek@redhat.com>
PR sanitizer/69099
mark_exp_read (op.value);
return parser_build_unary_op (op_loc, ADDR_EXPR, op);
case CPP_MULT:
- c_parser_consume_token (parser);
- exp_loc = c_parser_peek_token (parser)->location;
- op = c_parser_cast_expression (parser, NULL);
- finish = op.get_finish ();
- op = convert_lvalue_to_rvalue (exp_loc, op, true, true);
- ret.value = build_indirect_ref (op_loc, op.value, RO_UNARY_STAR);
- set_c_expr_source_range (&ret, op_loc, finish);
- return ret;
+ {
+ c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
+ op = c_parser_cast_expression (parser, NULL);
+ finish = op.get_finish ();
+ op = convert_lvalue_to_rvalue (exp_loc, op, true, true);
+ location_t combined_loc = make_location (op_loc, op_loc, finish);
+ ret.value = build_indirect_ref (combined_loc, op.value, RO_UNARY_STAR);
+ ret.src_range.m_start = op_loc;
+ ret.src_range.m_finish = finish;
+ return ret;
+ }
case CPP_PLUS:
if (!c_dialect_objc () && !in_system_header_at (input_location))
warning_at (op_loc,
--- /dev/null
+/* { dg-options "-fdiagnostics-show-caret" } */
+
+struct foo
+{
+ int x;
+};
+
+int test_1 (struct foo some_f)
+{
+ return *some_f.x; /* { dg-error "invalid type argument of unary ... .have .int.." } */
+/* { dg-begin-multiline-output "" }
+ return *some_f.x;
+ ^~~~~~~~~
+ { dg-end-multiline-output "" } */
+}
+
+int test_2 (struct foo some_f)
+{
+ return *some_f; /* { dg-error "invalid type argument of unary ... .have .struct foo.." } */
+/* { dg-begin-multiline-output "" }
+ return *some_f;
+ ^~~~~~~
+ { dg-end-multiline-output "" } */
+}