cpp.texi: Update.
authorNeil Booth <neilb@earthling.net>
Tue, 11 Jul 2000 13:39:09 +0000 (13:39 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Tue, 11 Jul 2000 13:39:09 +0000 (13:39 +0000)
* cpp.texi: Update.
* gcc.dg/cpp/cmdlne-C.c: New test.

From-SVN: r34957

gcc/ChangeLog
gcc/cpp.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/cmdlne-C.c [new file with mode: 0644]

index df3a1c3c73efcfc68b0f08633bf8f85d22b8c799..976ce9b6109c0a29dad45e70564e449ef1b04074 100644 (file)
@@ -1,3 +1,7 @@
+2000-07-11  Neil Booth  <NeilB@earthling.net>
+
+       * cpp.texi: Update.
+
 2000-07-11  Neil Booth  <NeilB@earthling.net>
 
        * cppinit.c: (cpp_reader_init): Allow digraphs by default.
index 74270d085302c20606ca5009fd8e8ffb3e49be78..0e30e1db0281d04f07b73b51a1fae1cdfada2702 100644 (file)
@@ -83,9 +83,9 @@ It is called a macro processor because it allows you to define
 The C preprocessor is intended only for macro processing of C, C++ and
 Objective C source files.  For macro processing of other files, you are
 strongly encouraged to use alternatives like M4, which will likely give
-you better results and avoid many problems.  For example, the C
-preprocessor sometimes outputs extra white space to avoid inadvertent C
-token concatenation, and this may cause problems with other languages.
+you better results and avoid many problems.  For example, normally the C
+preprocessor does not preserve arbitrary whitespace verbatim, but
+instead replaces each sequence with a single space.
 
 For use on C-like source files, the C preprocessor provides four
 separate facilities that you can use as you see fit:
@@ -2908,11 +2908,14 @@ and will be sent to a program which might be confused by the
 
 @item -C
 @findex -C
-Do not discard comments: pass them through to the output file.
-Comments appearing in arguments of a macro call will be copied to the
-output before the expansion of the macro call.
-
-You should be prepared for unwanted side effects when using -C.  For
+Do not discard comments.  All comments are passed through to the output
+file, except for comments in processed directives, which are deleted
+along with the directive.  Comments appearing in the expansion list of a
+macro will be preserved, and appear in place wherever the macro is
+invoked.
+
+You should be prepared for side effects when using -C; it causes the
+preprocessor to treat comments as tokens in their own right.  For
 example, macro redefinitions that were trivial when comments were
 replaced by a single space might become significant when comments are
 retained.  Also, comments appearing at the start of what would be a
index 63cac60285bd8ffe0af7277e84c32bc7d4210092..1d157f1c825061dd1036b1e780dac5a2c78d9fe2 100644 (file)
@@ -1,7 +1,11 @@
+2000-07-11  Neil Booth  <NeilB@earthling.net>
+
+       * gcc.dg/cpp/cmdlne-C.c: New.
+
 2000-07-09  Neil Booth  <NeilB@earthling.net>
 
-       * testsuite/gcc.dg/cpp/directiv.c: New tests.
-       * testsuite/gcc.dg/cpp/undef1.c: Update.
+       * gcc.dg/cpp/directiv.c: New tests.
+       * gcc.dg/cpp/undef1.c: Update.
 
 2000-07-08  Angela Marie Thomas <angela@cygnus.com>
 
diff --git a/gcc/testsuite/gcc.dg/cpp/cmdlne-C.c b/gcc/testsuite/gcc.dg/cpp/cmdlne-C.c
new file mode 100644 (file)
index 0000000..344718d
--- /dev/null
@@ -0,0 +1,31 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.  */
+
+/* { dg-do preprocess } */
+/* { dg-options -C } */
+
+/* Test -C doesn't fail with #define.  #define is the tricky case,
+   being the only directive that remembers its comments.
+
+   -C treats comments as tokens in their own right, so e.g. comment at
+   the beginning of a directive turns it into a non-directive.  */
+
+#define simple no comments
+#/**/define bad_directive              /* { dg-error "invalid" } */
+#define/**/obj_like/**/(some)/**/thing/**/
+#define fun_like(/**/x/**/,/**/y/**/)/**/
+/**/#define not_a_macro
+
+#if !defined simple || !defined obj_like || !defined fun_like
+#error Missed some macros with -C
+#endif
+
+#ifdef not_a_macro
+#error not_a_macro is!
+#endif
+
+/* Check obj_like2 doesn't expect arguments, and fun_like does.  */
+obj_like2
+fun_like (foo, bar)
+
+/* Check OK to redefine fun_like without comments in the params.  */
+#define fun_like(x, y)/**/