summaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-03 23:08:18 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-03 23:08:18 +0000
commiteb0d20b7a488402286290a18e539c8d02b12b62b (patch)
tree4d26b7322a593e1c409570f2ca4e99dccb8dc759 /libcpp
parent8e3caacfd31e8064785cba5c6ca2cec3a67d9f73 (diff)
downloadgcc-eb0d20b7a488402286290a18e539c8d02b12b62b.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@106454 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog8
-rw-r--r--libcpp/charset.c10
-rw-r--r--libcpp/errors.c27
-rw-r--r--libcpp/include/cpplib.h8
4 files changed, 40 insertions, 13 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 884002b1ea0..c0364802678 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,11 @@
+2005-11-03 Joseph S. Myers <joseph@codesourcery.com>
+
+ PR c++/17964
+ * 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.
+
2005-10-21 James E Wilson <wilson@specifix.com>
PR preprocessor/15220
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. */
diff --git a/libcpp/errors.c b/libcpp/errors.c
index 477101e3041..554d9e3c5f1 100644
--- a/libcpp/errors.c
+++ b/libcpp/errors.c
@@ -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);
}
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index 3c4d0d6cb5b..c5d8e85391a 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -435,6 +435,9 @@ struct cpp_options
/* True means return pragmas as tokens rather than processing
them directly. */
bool defer_pragmas;
+
+ /* True means error callback should be used for diagnostics. */
+ bool client_diagnostic;
};
/* Callback for header lookup for HEADER, which is the name of a
@@ -467,6 +470,11 @@ struct cpp_callbacks
int (*valid_pch) (cpp_reader *, const char *, int);
void (*read_pch) (cpp_reader *, const char *, int, const char *);
missing_header_cb missing_header;
+
+ /* Called to emit a diagnostic if client_diagnostic option is true.
+ This callback receives the translated message. */
+ void (*error) (cpp_reader *, int, const char *, va_list)
+ ATTRIBUTE_PRINTF(3,0);
};
/* Chain of directories to look for include files in. */