From patchwork Tue Jan 24 22:11:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 47925 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2396877wrn; Tue, 24 Jan 2023 14:12:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXtU/1+f31TFajO98P2FAoKN0TTTEOToEKEc5hoR3guFudqcfqlzyXIbb5vtkTwzhPttMQLH X-Received: by 2002:aa7:cacd:0:b0:49e:20f9:4ade with SMTP id l13-20020aa7cacd000000b0049e20f94ademr30201194edt.10.1674598346090; Tue, 24 Jan 2023 14:12:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674598346; cv=none; d=google.com; s=arc-20160816; b=t6sYgnHODPD18vayHCr9vywMPeYs12ev0JPTpQYfxTqWXVtQag79K76LVXWVqoqko8 LBDDLGGZ2WjAqNKxYzUVfxLdTjhopqBLs5rMYbRpIvkxo+4hgAQm2yh3lYPOlb0GZ3m1 TZmKvX/Apu9/kj1hJAZg/r5/MgTS+Sz3wa+cJg06GuDv8AzNtISsFiAcXHpLATN7J9eC EeV5N4XsHDROnCXDrWxWiSROeT01nmXWGFJ5C6QkX/cfgY/O6fAs/+t5ABs/lJUVt+Xf ocnDIJwoCmsLCsSIFB8DI7f/oFa2H0+cwG2y2ag6bOvcOBwgYMgBjRSmwQI8MSM/zGDO EyNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=J0TgpkmTP/nNOz9Nvi6/EI4I0tOKNcZrFZh7CiCN4SA=; b=LNAPHXPr9281522Qmf7u7Vjs8Gtegtl61WRj1pgICtHBYy12zumRVktOlq/XTaXq4e 0hVH6RCSs/QubQyu6adCWkpB2tYmOeclA0x4Tfpgl+1oZwz42ukerIE9WfcYr3jzhZ/U pW61qvwFP6rYV8OTBBXenAua8JF2VEFfluV/FiwI4d+1or+0v9w8/yMwG7ldMmPcaXiS rowlhRi6fb+30ipm3BFUxhGDjSVBZyiET5ctOS60/C+OM9QCR3U+sgywiWroe22s62sE +SUKmvYqTx9apwjem28sOoo2AbWu5L6LTLgvqwFvx5hVeaaSDlwCjg/hVrf5jLXWxx4A rCTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Jfj7AcjE; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id j4-20020a50ed04000000b0049ec99c546esi4305439eds.598.2023.01.24.14.12.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 14:12:26 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Jfj7AcjE; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5AD01385B50A for ; Tue, 24 Jan 2023 22:12:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5AD01385B50A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674598335; bh=J0TgpkmTP/nNOz9Nvi6/EI4I0tOKNcZrFZh7CiCN4SA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Jfj7AcjEzXg/fArwY1o+8SXIWE1uLSsRNneDRoyPIuD0EjM6ydbzX+SlyNAF1eeuV NXJEx+jYaSEJZHYjUjpk2UGS2iIYixa2eHV4lcPJ2iX5ZOVxsd+b8kxcb7P6Jq388E Uf8TmmhwfHYv7ztlbl4H/qXmGSASB0B3WVDQ6rSE= 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 [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 54BC73858C30 for ; Tue, 24 Jan 2023 22:11:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 54BC73858C30 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-622-ApcfIsqSM6CwvQrgHfig6g-1; Tue, 24 Jan 2023 17:11:29 -0500 X-MC-Unique: ApcfIsqSM6CwvQrgHfig6g-1 Received: by mail-qv1-f69.google.com with SMTP id l6-20020ad44446000000b00537721bfd2dso263021qvt.11 for ; Tue, 24 Jan 2023 14:11:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=J0TgpkmTP/nNOz9Nvi6/EI4I0tOKNcZrFZh7CiCN4SA=; b=XfOKIqvmtPv/ZPUfYmX74e8GQWYKFNoWmqbxcp3ic8RcE4JACVf+x8FOtFMGZPm0lU HObCO3A6/7rkubYGxJ/yJumweBL5rxgXNVmcgK6RzfW1Qfk4sprS3Xt15SE97TBATmMy D6O/ZjRfVSHuR8Rg3lU6fhJP5VjYix883sd97WJTzXGvouEhdwhkSxO9aKt+Kgdb4AEe xumdFjzEiZVybuRYCwR/nC/P/IHSkML+JOrHEf0sekjngiR3kIjRHJn5anyjdNWZOeyN 39UfEqC/Yv5I7yZuHAxl6rcBnTM5nIddAzOIxDfVrIwFgVAqA86iwBgnfBq/Q+8gg2mf TDog== X-Gm-Message-State: AFqh2koDgrPwJ14GSU1s/wUchUgYGQC7aygjWM2lQBEQlwWYo0AjO00e YcRfQV6OujrbUEZDtIP/AC0OxiafuHj3wFDDU56o3BHFGhcJH0UhtkOpmCB1z0nMTvPNj36yi57 KdD02xlpziG5QWb4bDdJoy6dKpqCzX3DfFU+L5RgoHjzofDTu50Ym0v0pyvx7qHqNAg== X-Received: by 2002:ac8:1199:0:b0:3b6:2c0d:87e8 with SMTP id d25-20020ac81199000000b003b62c0d87e8mr38134504qtj.35.1674598288919; Tue, 24 Jan 2023 14:11:28 -0800 (PST) X-Received: by 2002:ac8:1199:0:b0:3b6:2c0d:87e8 with SMTP id d25-20020ac81199000000b003b62c0d87e8mr38134474qtj.35.1674598288481; Tue, 24 Jan 2023 14:11:28 -0800 (PST) Received: from jason.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id y6-20020a05622a120600b003b2d890752dsm2051814qtx.88.2023.01.24.14.11.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 14:11:27 -0800 (PST) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: "" #pragma at BOF [PR108504] Date: Tue, 24 Jan 2023 17:11:23 -0500 Message-Id: <20230124221123.299474-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755943635253840264?= X-GMAIL-MSGID: =?utf-8?q?1755943635253840264?= Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- Since r11-2095 we pass flags to cp_lexer_get_preprocessor_token, and cp_lexer_new_main passes C_LEX_STRING_NO_JOIN when lexing most of the translation unit, but doesn't do that for the very first token; as a result, if the first token is a string literal, we try to join strings and get confused if that encounters a pragma. PR c++/108504 gcc/cp/ChangeLog: * parser.cc (cp_lexer_new_main): Pass C_LEX_STRING_NO_JOIN for first token, too. gcc/testsuite/ChangeLog: * g++.dg/ext/pragma1.C: New test. --- gcc/cp/parser.cc | 2 +- gcc/testsuite/g++.dg/ext/pragma1.C | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/ext/pragma1.C base-commit: 049a52909075117f5112971cc83952af2a818bc1 diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index b38c22e9a3d..07ec0e14491 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -705,7 +705,7 @@ cp_lexer_new_main (void) /* It's possible that parsing the first pragma will load a PCH file, which is a GC collection point. So we have to do that before allocating any memory. */ - cp_lexer_get_preprocessor_token (0, &token); + cp_lexer_get_preprocessor_token (C_LEX_STRING_NO_JOIN, &token); cp_parser_initial_pragma (&token); c_common_no_more_pch (); diff --git a/gcc/testsuite/g++.dg/ext/pragma1.C b/gcc/testsuite/g++.dg/ext/pragma1.C new file mode 100644 index 00000000000..bb258dac9a7 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/pragma1.C @@ -0,0 +1,4 @@ +// PR c++/108504 + +"1" // { dg-error "" } +#pragma GCC diagnostic push