This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Behaviors of `gcc -E -C'


There are various issues with -C which are not good.  It saves
comments within a macro expansion, so that each invocation reproduces
the comment.

This is nice, except that it doesn't work with C++ comments, since
stuff later on the line can be commented out (doh!) and it doesn't
work in directives, which don't expect comments as tokens.

These are fixable, if someone persuades me it's worth retaining the
comments in macro expansions.  We could convert C++ comments to C
comments when saving them, and have directives call a new function
_cpp_get_dtoken that filters out comment tokens.

What do you think, Zack?

In the meantime, I'm going to bootstrap the patch below, which turns
off saving comments in macro expansions, and if all is OK commit it.

As for 3.0.2, this patch plus a one-liner to fix the bug you mentioned
about comments in skipped blocks being output could be applied.  I'll
see what Mark thinks RSN.

Neil.

	* cppmacro.c (_cpp_create_definition): Leave comments off.

Index: cppmacro.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppmacro.c,v
retrieving revision 1.79
diff -u -p -r1.79 cppmacro.c
--- cppmacro.c	2001/10/08 06:15:13	1.79
+++ cppmacro.c	2001/10/08 18:02:46
@@ -1329,7 +1329,6 @@ _cpp_create_definition (pfile, node)
   else if (ctoken->type != CPP_EOF && !(ctoken->flags & PREV_WHITE))
     cpp_pedwarn (pfile, "ISO C requires whitespace after the macro name");
 
-  pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments);
   saved_cur_token = pfile->cur_token;
 
   if (macro->fun_like)
Index: doc/cpp.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/cpp.texi,v
retrieving revision 1.14
diff -u -p -r1.14 cpp.texi
--- cpp.texi	2001/09/24 22:53:10	1.14
+++ cpp.texi	2001/10/08 18:03:06
@@ -4228,15 +4228,11 @@ linemarkers.  @xref{Preprocessor Output}
 @item -C
 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.
+along with the directive.
 
-You should be prepared for side effects when using @option{-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
+You should be prepared for side effects when using @option{-C}; it
+causes the preprocessor to treat comments as tokens in their own right.
+For example, comments appearing at the start of what would be a
 directive line have the effect of turning that line into an ordinary
 source line, since the first token on the line is no longer a @samp{#}.
 




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]