On Tue, Dec 22, 2015 at 12:26:29PM -0500, David Malcolm wrote: > Currently, trunk emits this for a bad unary * in C: > > bad-dereference.c:10:10: error: invalid type argument of unary ‘*’ (have > ‘int’) > return *some_f.x; > ^ > > The following patch fixes the reported location to highlight the > expression that was attempted to be dereferenced: > > bad-dereference.c:10:10: error: invalid type argument of unary ‘*’ (have > ‘int’) > return *some_f.x; > ^~~~~~~~~ > > Based on another example from: > http://clang.llvm.org/diagnostics.html > albeit within the "Precision in Wording" example; I didn't change the > wording.
fwiw gcc's wording seems better to me. > +++ b/gcc/c/c-parser.c > @@ -6691,8 +6691,12 @@ c_parser_unary_expression (c_parser *parser) > 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); > + { I'd find these braces less confusing if they were for the entire case not just part of it. Trev