aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2005-10-04 18:06:19 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2005-10-04 18:06:19 +0000
commitcbc43ae091a468f438f851e454ac4454bb89f476 (patch)
tree545ffe9bc98a6d6ff50b698d701fdeaba1622b1d /gcc
parent44d251729691376ab96450f3b8e580a87c055b95 (diff)
downloadgcc-cbc43ae091a468f438f851e454ac4454bb89f476.zip
gcc-cbc43ae091a468f438f851e454ac4454bb89f476.tar.gz
gcc-cbc43ae091a468f438f851e454ac4454bb89f476.tar.bz2
re PR preprocessor/13726 (cpp -C -dI loses comments on same line as #include directives)
libcpp/ PR preprocessor/13726 * directives.c (check_eol_return_comments): New static function. (parse_include): Add buf parameter. Change all callers. (do_include_common): If not discard comments, turn on save_comments. Pass collected comments to include callback. * include/cpplib.h (struct cpp_callbacks): Add new parameter to include callback: cpp_token list. gcc/ PR preprocessor/13726 * c-ppoutput.c (cb_include): Add comments parameter, and print out any comments passed in. gcc/testsuite/ PR preprocessor/13726 * gcc.dg/cpp/cmdlne-dI-C.c: New test. * gcc.dg/cpp/cmdlne-dI-C.h: New file. From-SVN: r104951
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/c-ppoutput.c22
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/cpp/cmdlne-dI-C.c11
-rw-r--r--gcc/testsuite/gcc.dg/cpp/cmdlne-dI-C.h1
5 files changed, 42 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 088f0e7..c3723cd 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2005-10-04 Ian Lance Taylor <ian@airs.com>
+
+ PR preprocessor/13726
+ * c-ppoutput.c (cb_include): Add comments parameter, and print out
+ any comments passed in.
+
2005-10-04 Andrew Pinski <pinskia@physics.uc.edu>
* tree.c (annotate_with_file_line): Fix typo.
diff --git a/gcc/c-ppoutput.c b/gcc/c-ppoutput.c
index 1cdbb67..692ea7a 100644
--- a/gcc/c-ppoutput.c
+++ b/gcc/c-ppoutput.c
@@ -54,7 +54,7 @@ static void cb_line_change (cpp_reader *, const cpp_token *, int);
static void cb_define (cpp_reader *, source_location, cpp_hashnode *);
static void cb_undef (cpp_reader *, source_location, cpp_hashnode *);
static void cb_include (cpp_reader *, source_location, const unsigned char *,
- const char *, int);
+ const char *, int, const cpp_token **);
static void cb_ident (cpp_reader *, source_location, const cpp_string *);
static void cb_def_pragma (cpp_reader *, source_location);
static void cb_read_pch (cpp_reader *pfile, const char *name,
@@ -336,13 +336,27 @@ cb_undef (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location line,
static void
cb_include (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location line,
- const unsigned char *dir, const char *header, int angle_brackets)
+ const unsigned char *dir, const char *header, int angle_brackets,
+ const cpp_token **comments)
{
maybe_print_line (line);
if (angle_brackets)
- fprintf (print.outf, "#%s <%s>\n", dir, header);
+ fprintf (print.outf, "#%s <%s>", dir, header);
else
- fprintf (print.outf, "#%s \"%s\"\n", dir, header);
+ fprintf (print.outf, "#%s \"%s\"", dir, header);
+
+ if (comments != NULL)
+ {
+ while (*comments != NULL)
+ {
+ if ((*comments)->flags & PREV_WHITE)
+ putc (' ', print.outf);
+ cpp_output_token (*comments, print.outf);
+ ++comments;
+ }
+ }
+
+ putc ('\n', print.outf);
print.src_line++;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8bc316d..a397ea9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2005-10-04 Ian Lance Taylor <ian@airs.com>
+
+ PR preprocessor/13726
+ * gcc.dg/cpp/cmdlne-dI-C.c: New test.
+ * gcc.dg/cpp/cmdlne-dI-C.h: New file.
+
2005-10-04 Richard Guenther <rguenther@suse.de>
PR c/23576
diff --git a/gcc/testsuite/gcc.dg/cpp/cmdlne-dI-C.c b/gcc/testsuite/gcc.dg/cpp/cmdlne-dI-C.c
new file mode 100644
index 0000000..6b4bfee
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/cmdlne-dI-C.c
@@ -0,0 +1,11 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc. */
+/* PR 13726 */
+
+/* { dg-do preprocess } */
+/* { dg-options "-dI -C" } */
+
+#include "cmdlne-dI-C.h" /* #include comment */
+/* comment 2 */
+
+/* { dg-final { scan-file cmdlne-dI-C.i "#include c+omment" } } */
+/* { dg-final { scan-file cmdlne-dI-C.i "header file c+omment" } } */
diff --git a/gcc/testsuite/gcc.dg/cpp/cmdlne-dI-C.h b/gcc/testsuite/gcc.dg/cpp/cmdlne-dI-C.h
new file mode 100644
index 0000000..5021488
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/cmdlne-dI-C.h
@@ -0,0 +1 @@
+/* header file comment */