From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 447113858D28; Wed, 17 Nov 2021 16:32:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 447113858D28 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5340] libcpp: Fix up handling of block comments in -fdirectives-only mode [PR103130] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: dd159a4167ca19b5ff26e7156333c88e854943bf X-Git-Newrev: 049f0efeaa77b43a508172161ca040feb6bb5622 Message-Id: <20211117163223.447113858D28@sourceware.org> Date: Wed, 17 Nov 2021 16:32:23 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Nov 2021 16:32:23 -0000 https://gcc.gnu.org/g:049f0efeaa77b43a508172161ca040feb6bb5622 commit r12-5340-g049f0efeaa77b43a508172161ca040feb6bb5622 Author: Jakub Jelinek Date: Wed Nov 17 17:31:40 2021 +0100 libcpp: Fix up handling of block comments in -fdirectives-only mode [PR103130] Normal preprocessing, -fdirectives-only preprocessing before the Nathan's rewrite, and all other compilers I've tried on godbolt treat even \*/ as end of a block comment, but the new -fdirectives-only handling doesn't. 2021-11-17 Jakub Jelinek PR preprocessor/103130 * lex.c (cpp_directive_only_process): Treat even \*/ as end of block comment. * c-c++-common/cpp/dir-only-9.c: New test. Diff: --- gcc/testsuite/c-c++-common/cpp/dir-only-9.c | 13 +++++++++++++ libcpp/lex.c | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/c-c++-common/cpp/dir-only-9.c b/gcc/testsuite/c-c++-common/cpp/dir-only-9.c new file mode 100644 index 00000000000..d11cd97cb71 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cpp/dir-only-9.c @@ -0,0 +1,13 @@ +/* PR preprocessor/103130 */ +/* { dg-do preprocess } */ +/* { dg-options -fdirectives-only } */ + +/*\ + * this is a comment +\*/ + +int +main () +{ + return 0; +} diff --git a/libcpp/lex.c b/libcpp/lex.c index 6a4fbce6030..8188e33b07d 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -4891,7 +4891,7 @@ cpp_directive_only_process (cpp_reader *pfile, break; case '*': - if (pos > peek && !esc) + if (pos > peek) star = is_block; esc = false; break;