OSDN Git Service

libcpp
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 2 May 2007 19:33:44 +0000 (19:33 +0000)
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 2 May 2007 19:33:44 +0000 (19:33 +0000)
PR preprocessor/28709:
* macro.c (paste_tokens): Remove PASTE_LEFT from the old lhs.
gcc/testsuite
PR preprocessor/28709:
* gcc.dg/cpp/pr28709.c: New file.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@124356 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/pr28709.c [new file with mode: 0644]
libcpp/ChangeLog
libcpp/macro.c

index 287a097..d8493a1 100644 (file)
@@ -1,3 +1,8 @@
+2007-05-02  Tom Tromey  <tromey@redhat.com>
+
+       PR preprocessor/28709:
+       * gcc.dg/cpp/pr28709.c: New file.
+
 2007-05-02  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/31146
diff --git a/gcc/testsuite/gcc.dg/cpp/pr28709.c b/gcc/testsuite/gcc.dg/cpp/pr28709.c
new file mode 100644 (file)
index 0000000..11cccbe
--- /dev/null
@@ -0,0 +1,8 @@
+/* Copyright (C) 2006 Free Software Foundation, Inc.  */
+/* PR preprocessor/28709 */
+
+/* { dg-do compile } */
+#define foo - ## >>
+foo;
+/* { dg-error "expected identifier.*'-'" "" { target *-*-* } 6 } */
+/* { dg-error pasting "" { target *-*-* } 6 } */
index a56357f..0193de4 100644 (file)
@@ -1,3 +1,8 @@
+2007-05-02  Tom Tromey  <tromey@redhat.com>
+
+       PR preprocessor/28709:
+       * macro.c (paste_tokens): Remove PASTE_LEFT from the old lhs.
+
 2007-03-30  Michael Meissner  <michael.meissner@amd.com>
 
        * directives.c (lex_macro_node_from_str): Fix alloca call to be
index ede29ff..748635f 100644 (file)
@@ -432,19 +432,18 @@ static bool
 paste_tokens (cpp_reader *pfile, const cpp_token **plhs, const cpp_token *rhs)
 {
   unsigned char *buf, *end, *lhsend;
-  const cpp_token *lhs;
+  cpp_token *lhs;
   unsigned int len;
 
-  lhs = *plhs;
-  len = cpp_token_len (lhs) + cpp_token_len (rhs) + 1;
+  len = cpp_token_len (*plhs) + cpp_token_len (rhs) + 1;
   buf = (unsigned char *) alloca (len);
-  end = lhsend = cpp_spell_token (pfile, lhs, buf, false);
+  end = lhsend = cpp_spell_token (pfile, *plhs, buf, false);
 
   /* Avoid comment headers, since they are still processed in stage 3.
      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_EQ)
+  if ((*plhs)->type == CPP_DIV && rhs->type != CPP_EQ)
     *end++ = ' ';
   end = cpp_spell_token (pfile, rhs, end, false);
   *end = '\n';
@@ -454,13 +453,22 @@ paste_tokens (cpp_reader *pfile, const cpp_token **plhs, const cpp_token *rhs)
 
   /* Set pfile->cur_token as required by _cpp_lex_direct.  */
   pfile->cur_token = _cpp_temp_token (pfile);
-  *plhs = _cpp_lex_direct (pfile);
+  lhs = _cpp_lex_direct (pfile);
   if (pfile->buffer->cur != pfile->buffer->rlimit)
     {
+      source_location saved_loc = lhs->src_loc;
+
       _cpp_pop_buffer (pfile);
       _cpp_backup_tokens (pfile, 1);
       *lhsend = '\0';
 
+      /* We have to remove the PASTE_LEFT flag from the old lhs, but
+        we want to keep the new location.  */
+      *lhs = **plhs;
+      *plhs = lhs;
+      lhs->src_loc = saved_loc;
+      lhs->flags &= ~PASTE_LEFT;
+
       /* Mandatory error for all apart from assembler.  */
       if (CPP_OPTION (pfile, lang) != CLK_ASM)
        cpp_error (pfile, CPP_DL_ERROR,
@@ -469,6 +477,7 @@ paste_tokens (cpp_reader *pfile, const cpp_token **plhs, const cpp_token *rhs)
       return false;
     }
 
+  *plhs = lhs;
   _cpp_pop_buffer (pfile);
   return true;
 }