From e4b33ee5e46bc68fa06d422c3900e8a1f6382e60 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 6 Apr 2015 19:01:50 +0200 Subject: [PATCH] re PR preprocessor/61977 (powerpc preprocessor breaks on lines that end with "vector") 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 | 5 +++++ gcc/testsuite/gcc.dg/cpp/pr61977.c | 4 ++++ libcpp/ChangeLog | 6 ++++++ libcpp/lex.c | 7 +++++-- 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/cpp/pr61977.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9849363b5c3..6a0d0001274 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-04-06 Jakub Jelinek + + PR preprocessor/61977 + * gcc.dg/cpp/pr61977.c: New test. + 2015-04-06 Ilya Enkovich * 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 index 00000000000..faad4737497 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/pr61977.c @@ -0,0 +1,4 @@ +/* PR preprocessor/61977 */ +/* { dg-do preprocess } */ + +vector diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 829abba8cf9..2ad145f8cc8 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,9 @@ +2015-04-06 Jakub Jelinek + + 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 PR preprocessor/61977 diff --git a/libcpp/lex.c b/libcpp/lex.c index d1e221110fc..ac96ff8dbe5 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -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; -- 2.30.2