re PR c++/17964 (cpp error messages contain wrong line in C++)
gcc: PR c++/17964 * diagnostic.c (diagnostic_set_info_translated): New function. (diagnostic_set_info): Use it. Add comment. * diagnostic.h (diagnostic_set_info_translated): Declare. gcc/cp: * error.c (cp_cpp_error): New function. * cp-tree.h (cp_cpp_error): Declare. * parser.c (cp_lexer_new_main): Set CPP option client_diagnostic and error callback after lexing. gcc/testsuite: * g++.dg/cpp/string-1.C: New test. libcpp: * include/cpplib.h (struct cpp_options): Add client_diagnostic. (struct cpp_callbacks): Add error. * errors.c (cpp_error): If client_diagnostic, use error callback. * charset.c (convert_escape): Don't use %03o in diagnostic. From-SVN: r106454
This commit is contained in:
parent
b0ae01d7f9
commit
178b58b59e
13 changed files with 132 additions and 19 deletions
|
@ -140,20 +140,25 @@ cpp_error (cpp_reader * pfile, int level, const char *msgid, ...)
|
|||
|
||||
va_start (ap, msgid);
|
||||
|
||||
if (CPP_OPTION (pfile, traditional))
|
||||
{
|
||||
if (pfile->state.in_directive)
|
||||
src_loc = pfile->directive_line;
|
||||
else
|
||||
src_loc = pfile->line_table->highest_line;
|
||||
}
|
||||
if (CPP_OPTION (pfile, client_diagnostic))
|
||||
pfile->cb.error (pfile, level, _(msgid), ap);
|
||||
else
|
||||
{
|
||||
src_loc = pfile->cur_token[-1].src_loc;
|
||||
}
|
||||
if (CPP_OPTION (pfile, traditional))
|
||||
{
|
||||
if (pfile->state.in_directive)
|
||||
src_loc = pfile->directive_line;
|
||||
else
|
||||
src_loc = pfile->line_table->highest_line;
|
||||
}
|
||||
else
|
||||
{
|
||||
src_loc = pfile->cur_token[-1].src_loc;
|
||||
}
|
||||
|
||||
if (_cpp_begin_message (pfile, level, src_loc, 0))
|
||||
v_message (msgid, ap);
|
||||
if (_cpp_begin_message (pfile, level, src_loc, 0))
|
||||
v_message (msgid, ap);
|
||||
}
|
||||
|
||||
va_end (ap);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue