aboutsummaryrefslogtreecommitdiff
path: root/libcpp/directives.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2008-05-21 21:52:57 +0000
committerTom Tromey <tromey@gcc.gnu.org>2008-05-21 21:52:57 +0000
commit5d6342ebc23344e8168b1589589b68f7b6781f66 (patch)
treea31b212aa429bae765ecae0b494fda6a486c56a5 /libcpp/directives.c
parent0fda18dd70beee1713ba7b2bd8f04222fbe535bb (diff)
downloadgcc-5d6342ebc23344e8168b1589589b68f7b6781f66.zip
gcc-5d6342ebc23344e8168b1589589b68f7b6781f66.tar.gz
gcc-5d6342ebc23344e8168b1589589b68f7b6781f66.tar.bz2
re PR preprocessor/27777 (Bad diagnostic emission when #error contains a trigraph)
gcc/testsuite PR preprocessor/27777: * gcc.dg/cpp/pr27777.c: New file. libcpp PR preprocessor/27777: * lex.c (cpp_output_line_to_string): New function. * internal.h (_cpp_begin_message): Don't declare. * errors.c (_cpp_begin_message): Now static. * include/cpplib.h (cpp_output_line_to_string): Declare. * directives.c (do_diagnostic): Rewrote. Use cpp_output_line_to_string. Don't use _cpp_begin_message. From-SVN: r135740
Diffstat (limited to 'libcpp/directives.c')
-rw-r--r--libcpp/directives.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/libcpp/directives.c b/libcpp/directives.c
index 9954796..8e7778d 100644
--- a/libcpp/directives.c
+++ b/libcpp/directives.c
@@ -1016,14 +1016,20 @@ _cpp_do_file_change (cpp_reader *pfile, enum lc_reason reason,
static void
do_diagnostic (cpp_reader *pfile, int code, int print_dir)
{
- if (_cpp_begin_message (pfile, code, pfile->cur_token[-1].src_loc, 0))
- {
- if (print_dir)
- fprintf (stderr, "#%s ", pfile->directive->name);
- pfile->state.prevent_expansion++;
- cpp_output_line (pfile, stderr);
- pfile->state.prevent_expansion--;
- }
+ const unsigned char *dir_name;
+ unsigned char *line;
+ source_location src_loc = pfile->cur_token[-1].src_loc;
+
+ if (print_dir)
+ dir_name = pfile->directive->name;
+ else
+ dir_name = NULL;
+ pfile->state.prevent_expansion++;
+ line = cpp_output_line_to_string (pfile, dir_name);
+ pfile->state.prevent_expansion--;
+
+ cpp_error_with_line (pfile, code, src_loc, 0, "%s", line);
+ free (line);
}
static void