re PR preprocessor/61977 (powerpc preprocessor breaks on lines that end with "vector")
authorJakub Jelinek <jakub@redhat.com>
Mon, 6 Apr 2015 17:01:50 +0000 (19:01 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 6 Apr 2015 17:01:50 +0000 (19:01 +0200)
PR preprocessor/61977
* lex.c (cpp_peek_token): If peektok is CPP_EOF, back it up
with all tokens peeked by the current function.

* gcc.dg/cpp/pr61977.c: New test.

From-SVN: r221882

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

index 9849363b5c3327fad26d9d6e607f7c935b0d27c2..6a0d0001274d093f95000ca7cae2dfe3fee69a32 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR preprocessor/61977
+       * gcc.dg/cpp/pr61977.c: New test.
+
 2015-04-06  Ilya Enkovich  <ilya.enkovich@intel.com>
 
        * gcc.dg/lto/chkp-ctor-merge_0.c: New.
diff --git a/gcc/testsuite/gcc.dg/cpp/pr61977.c b/gcc/testsuite/gcc.dg/cpp/pr61977.c
new file mode 100644 (file)
index 0000000..faad473
--- /dev/null
@@ -0,0 +1,4 @@
+/* PR preprocessor/61977 */
+/* { dg-do preprocess } */
+
+vector
index 829abba8cf916ee60496d8c23c3b5a9fa90e5d4a..2ad145f8cc8e805381276d992525e6d551d3eec3 100644 (file)
@@ -1,3 +1,9 @@
+2015-04-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR preprocessor/61977
+       * lex.c (cpp_peek_token): If peektok is CPP_EOF, back it up
+       with all tokens peeked by the current function.
+
 2015-04-02  Jakub Jelinek  <jakub@redhat.com>
 
        PR preprocessor/61977
index d1e221110fce4420e73077cf92036e1838505568..ac96ff8dbe5d77b88c931afaf39e306411bc19bf 100644 (file)
@@ -2090,11 +2090,14 @@ cpp_peek_token (cpp_reader *pfile, int index)
     {
       peektok = _cpp_lex_token (pfile);
       if (peektok->type == CPP_EOF)
-       return peektok;
+       {
+         index--;
+         break;
+       }
     }
   while (index--);
 
-  _cpp_backup_tokens_direct (pfile, count + 1);
+  _cpp_backup_tokens_direct (pfile, count - index);
   pfile->keep_tokens--;
   pfile->cb.line_change = line_change;