Message ID | 4FAB1D00.2060607@oracle.com |
---|---|
State | New |
Headers | show |
Paolo Carlini <paolo.carlini@oracle.com> writes: > in case my message ends up garbled, the carets do not point to && > (column 13), two times point to b (column 20), which is obviously > wrong. In other terms, all the columns are 20, all wrong. The new caret support does seem to have revealed a bunch of places where the column info in error messages was pretty screwy... I guess nobody paid much attention to it before... :] Should these get reported as bugzilla bugs...? -miles
On 10 May 2012 07:55, Miles Bader <miles@gnu.org> wrote: > Paolo Carlini <paolo.carlini@oracle.com> writes: >> in case my message ends up garbled, the carets do not point to && >> (column 13), two times point to b (column 20), which is obviously >> wrong. In other terms, all the columns are 20, all wrong. > > The new caret support does seem to have revealed a bunch of places > where the column info in error messages was pretty screwy... I guess > nobody paid much attention to it before... :] > > Should these get reported as bugzilla bugs...? In principle, yes. In practice, there are already so many known issues that adding more would just waste contributors time doing bugzilla administration. So help would very much appreciated. In particular, the C FE and the preprocessor are in much worse shape in terms of locations than the C++ FE. Some issues may be hard but many of them are a matter of setting a breakpoint at the error, going up the frame, and figuring out where the correct location could be got from. Then passing it down to the error so it can use the correct location. If you can figure out that but can't/won't write a patch, then please open a PR. Cheers, Manuel.
Looks good. Jason
Index: parser.c =================================================================== --- parser.c (revision 187362) +++ parser.c (working copy) @@ -1621,6 +1621,8 @@ typedef struct cp_parser_expression_stack_entry enum tree_code tree_type; /* Precedence of the binary operation we are parsing. */ enum cp_parser_prec prec; + /* Location of the binary operation we are parsing. */ + location_t loc; } cp_parser_expression_stack_entry; /* The stack for storing partial expressions. We only need NUM_PREC_VALUES @@ -7277,7 +7279,7 @@ cp_parser_binary_expression (cp_parser* parser, bo cp_parser_expression_stack_entry *sp = &stack[0]; tree lhs, rhs; cp_token *token; - location_t loc; + location_t loc = input_location; enum tree_code tree_type, lhs_type, rhs_type; enum cp_parser_prec new_prec, lookahead_prec; tree overload; @@ -7290,7 +7292,6 @@ cp_parser_binary_expression (cp_parser* parser, bo { /* Get an operator token. */ token = cp_lexer_peek_token (parser->lexer); - loc = token->location; if (warn_cxx0x_compat && token->type == CPP_RSHIFT @@ -7320,6 +7321,7 @@ cp_parser_binary_expression (cp_parser* parser, bo get_rhs: tree_type = binops_by_token[token->type].tree_type; + loc = token->location; /* We used the operator token. */ cp_lexer_consume_token (parser->lexer); @@ -7349,6 +7351,7 @@ cp_parser_binary_expression (cp_parser* parser, bo stack overflows. */ sp->prec = prec; sp->tree_type = tree_type; + sp->loc = loc; sp->lhs = lhs; sp->lhs_type = lhs_type; sp++; @@ -7370,6 +7373,7 @@ cp_parser_binary_expression (cp_parser* parser, bo --sp; prec = sp->prec; tree_type = sp->tree_type; + loc = sp->loc; rhs = lhs; rhs_type = lhs_type; lhs = sp->lhs;