On 12/22/2015 10:26 AM, 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.
Successfully bootstrapped®rtested on x86_64-pc-linux-gnu.
OK for trunk in stage 3?
gcc/c/ChangeLog:
* 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.
gcc/testsuite/ChangeLog:
* gcc.dg/bad-dereference.c: New test case.
I agree with Trevor here, move those curlys out to enclose the entire
switch case. It'll mean reformatting, but, meh...
Approved with that change.
jeff