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]
Other format: [Raw text]

Fix minor paste bug


I noticed this amusing bug whilst working on the line-at-a-time
code.

Neil.

	* cppmacro.c (paste_tokens): Only allow / to paste with =.
testsuite:
	* gcc.dg/cpp/paste13.c: New test.

Index: cppmacro.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppmacro.c,v
retrieving revision 1.125
diff -u -p -r1.125 cppmacro.c
--- cppmacro.c	28 Sep 2002 00:30:36 -0000	1.125
+++ cppmacro.c	9 Oct 2002 09:54:16 -0000
@@ -442,8 +442,7 @@ paste_tokens (pfile, plhs, rhs)
      It is simpler to insert a space here, rather than modifying the
      lexer to ignore comments in some circumstances.  Simply returning
      false doesn't work, since we want to clear the PASTE_LEFT flag.  */
-  if (lhs->type == CPP_DIV
-      && (rhs->type == CPP_MULT || rhs->type == CPP_DIV))
+  if (lhs->type == CPP_DIV && rhs->type != CPP_EQ)
     *end++ = ' ';
   end = cpp_spell_token (pfile, rhs, end);
   *end = '\0';
Index: testsuite/gcc.dg/cpp/paste13.c
===================================================================
RCS file: testsuite/gcc.dg/cpp/paste13.c
diff -N testsuite/gcc.dg/cpp/paste13.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/cpp/paste13.c	9 Oct 2002 09:54:16 -0000
@@ -0,0 +1,9 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.  */
+
+/* { dg-do preprocess } */
+
+/* This used to be recognized as a comment when lexing after pasting
+   spellings.  Neil Booth, 9 Oct 2002.  */
+
+#define a /##/=
+a			/* { dg-warning "valid preprocessing tok" } */


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