From 178b58b59e18dcb713ef8ed45f79ffa072c617a5 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Thu, 3 Nov 2005 23:08:18 +0000 Subject: 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 --- libcpp/charset.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'libcpp/charset.c') diff --git a/libcpp/charset.c b/libcpp/charset.c index 2c87fb6ac27..78c89816735 100644 --- a/libcpp/charset.c +++ b/libcpp/charset.c @@ -1277,8 +1277,14 @@ convert_escape (cpp_reader *pfile, const uchar *from, const uchar *limit, cpp_error (pfile, CPP_DL_PEDWARN, "unknown escape sequence '\\%c'", (int) c); else - cpp_error (pfile, CPP_DL_PEDWARN, - "unknown escape sequence: '\\%03o'", (int) c); + { + /* diagnostic.c does not support "%03o". When it does, this + code can use %03o directly in the diagnostic again. */ + char buf[32]; + sprintf(buf, "%03o", (int) c); + cpp_error (pfile, CPP_DL_PEDWARN, + "unknown escape sequence: '\\%s'", buf); + } } /* Now convert what we have to the execution character set. */ -- cgit v1.2.3