From patchwork Wed Nov 17 09:22:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 47805 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 91E25385840C for ; Wed, 17 Nov 2021 09:23:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 91E25385840C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1637141038; bh=ykmdHUbYygOsbF3PveL+IoZVuoczLpYBqkmt1GNCXyE=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=UFJRN7D0M46RbtkTCAz7dxIccZJNIZoz7uCKBLly2gJVPwl3wmvoDTPpTBhQdylsP s6r8/rpkvAg0g/eKGmhES+H3fCVsxY6oR9NPc3n4eqJcFBL0AfG15jhF23Va1+VRTo l0Q3bgqEBmSj1p939xzn7aHfjjCOMS3NVBgi9WgY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTPS id 1A6F6385AC32 for ; Wed, 17 Nov 2021 09:22:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1A6F6385AC32 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-545-h7yaEelsPS24N80XTgpTdA-1; Wed, 17 Nov 2021 04:22:43 -0500 X-MC-Unique: h7yaEelsPS24N80XTgpTdA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6EE221006AA2; Wed, 17 Nov 2021 09:22:42 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E4730509FF; Wed, 17 Nov 2021 09:22:35 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 1AH9MX6l1391446 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Nov 2021 10:22:33 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 1AH9MWaM1391445; Wed, 17 Nov 2021 10:22:32 +0100 Date: Wed, 17 Nov 2021 10:22:32 +0100 To: "Joseph S. Myers" , Marek Polacek , Jason Merrill , David Malcolm Subject: [PATCH] libcpp: Fix up handling of block comments in -fdirectives-only mode [PR103130] Message-ID: <20211117092232.GJ2710@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! 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. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 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. Jakub --- libcpp/lex.c.jj 2021-11-01 14:37:06.706853026 +0100 +++ libcpp/lex.c 2021-11-16 16:54:04.022644499 +0100 @@ -4493,7 +4493,7 @@ cpp_directive_only_process (cpp_reader * break; case '*': - if (pos > peek && !esc) + if (pos > peek) star = is_block; esc = false; break; --- gcc/testsuite/c-c++-common/cpp/dir-only-9.c.jj 2021-11-16 16:56:57.121217975 +0100 +++ gcc/testsuite/c-c++-common/cpp/dir-only-9.c 2021-11-16 16:56:14.524815094 +0100 @@ -0,0 +1,13 @@ +/* PR preprocessor/103130 */ +/* { dg-do preprocess } */ +/* { dg-options -fdirectives-only } */ + +/*\ + * this is a comment +\*/ + +int +main () +{ + return 0; +}