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]

cpplib [branch]: Unbreak -C


Mark,

Subject to the usual bootstrap / regression test, I'd like to commit
this to the branch.  It both fixes a 2.95.x regression (-C is quite
broken), and is IMO obviously safe.

We've got a PR about it, and a mail today on GCC-bugs.

Is that OK?

Neil.

	* cpplex.c (_cpp_lex_token): Don't save comments if skipping.
	* cppmacro.c (_cpp_create_definition): Leave comments off.

	* doc/cpp.texi: Update.

Index: cpplex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplex.c,v
retrieving revision 1.129.2.11
diff -u -p -r1.129.2.11 cpplex.c
--- cpplex.c	2001/08/03 18:05:10	1.129.2.11
+++ cpplex.c	2001/10/08 18:31:14
@@ -1033,7 +1033,7 @@ _cpp_lex_token (pfile, result)
 	}
 
       /* Skipping the comment has updated buffer->read_ahead.  */
-      if (!pfile->state.save_comments)
+      if (!pfile->state.save_comments || pfile->skipping)
 	{
 	  result->flags |= PREV_WHITE;
 	  goto next_char;
Index: cppmacro.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppmacro.c,v
retrieving revision 1.44.2.7
diff -u -p -r1.44.2.7 cppmacro.c
--- cppmacro.c	2001/08/23 18:19:59	1.44.2.7
+++ cppmacro.c	2001/10/08 18:31:25
@@ -1396,9 +1396,6 @@ _cpp_create_definition (pfile, node)
   else if (token->type != CPP_EOF && !(token->flags & PREV_WHITE))
     cpp_pedwarn (pfile, "ISO C requires whitespace after the macro name");
 
-  /* Setting it here means we don't catch leading comments.  */
-  pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments);
-
   for (;;)
     {
       /* Check the stringifying # constraint 6.10.3.2.1 of
Index: doc/cpp.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/cpp.texi,v
retrieving revision 1.2.2.8
diff -u -p -r1.2.2.8 cpp.texi
--- cpp.texi	2001/06/27 15:08:23	1.2.2.8
+++ cpp.texi	2001/10/08 18:31:48
@@ -4219,15 +4219,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]