From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x112e.google.com (mail-yw1-x112e.google.com [IPv6:2607:f8b0:4864:20::112e]) by sourceware.org (Postfix) with ESMTPS id 4657D385C33A for ; Thu, 30 Nov 2023 22:20:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4657D385C33A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4657D385C33A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701382840; cv=none; b=Mek03/haEWP+whUC7eqbOccwS1iacanRxyaMwZAhNVfriC5cmsHvyHrKiZJuDJ6vQleJz11PjIWff/d9S24Ght3/2UsIB/OajrllwselvJzmxewbItpqeVgc4N+oMbVa/pyXICVc6zUbJED7nBNOoZFXijVGb77z+X8T6kEhwQk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701382840; c=relaxed/simple; bh=8iXXEUFdlI1mtPmA5jXbXugTSPDEUoUKszej24JimyI=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=H3kpOMp6Hpd0H3/3xPIiH9EXBa7NLpbpGzEOseqrFafZKdZst66AEt/NG6fw4+zdjR6eYoi2buyu3YQAruRTSSkoB4ZDRDI7+Gxdh2E2kITRjlJSbBZl4wQU8YFeed+pYS7TpwiGb/yLticYLCztvOYw9Wa9BWE2fpDGYpy6xV8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-5cd81e76164so16596127b3.1 for ; Thu, 30 Nov 2023 14:20:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701382838; x=1701987638; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=45L0uHxvP8ZnUO+bCHjcz4h9rPZ3oyIzi5qyfHfp7lE=; b=BRn5bE7vO2i2vxZ15XD0Dvb6YDHW1sSXMXKKwGbZTtHgsokrTw890g+rmMhNVPBFVz ki7waCA+2hujuqHRzshuwNZW9EcrBcMKknCHh6/n/mF5b1eGylDUTRPO7ml+jyFDS8h+ Z0W9S5mr32n243k6/xcmgM+h2MYUUkSbhajKadrdG8yt9RDQ3LJcTP57OcDVNn/ui2ug uPSX6KPURvXmUscW2+1qZwZPkRZFLaKBTSKUw5m17oj/lXomrZ4MJoCCV0EnKX+12evf jhTNzU+ak2eX0mmGg708bhghsj2WnwcYi5CY9wx2xpy09brYAsKTIUoPktOM35eMJrG8 aCEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701382838; x=1701987638; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=45L0uHxvP8ZnUO+bCHjcz4h9rPZ3oyIzi5qyfHfp7lE=; b=GCdNtfyg+9KTh0lfpj5XxmudVgXdYqL6Ubn9VYPTa3ISNFQd3zQ/LyJ2UHV6q3gQmu Z7YMI9WSzCapZCiVNoFLbBL749dufG+sul3TOUg4WzDyoCa6SFU4lRQyEO0EXzZPBYMR 0mKXDBPOjbku94kJW9JBEdsLCqs1Xa3zFr8TXhju15m+twsfnZWowykGcr61EfffQJDv Pnx1K995EGdot4Zfrve0DP0l/EpP5YO7ubzvApLxb8SxZVJIm7Id7Rc+YNfAmxBYlOm+ VgDb+06Tki6WG0ET1XNxwVHxgOxwyKu61yBf2ELxHkmK6xgqB1bfR+XuzdBkn3RW2TYY YUwQ== X-Gm-Message-State: AOJu0Yye1dYaw/X+pEQ9K1gTrD9p+8WhMLtp/z3H5KTpYQwuKCY1JXp1 YeWPBChNT7+3EKFhEVlOrOqU3T2FGvDsu4RHlas= X-Google-Smtp-Source: AGHT+IFizhXMO1wkoiXPLDyb9JhXBX7X1e+TVq3f1iCNbptHKpKuYXoPgH2OwmxbQoXlbtXa23vI5+xFBrryTjcVHXU= X-Received: by 2002:a81:ad51:0:b0:5d3:f7ef:4963 with SMTP id l17-20020a81ad51000000b005d3f7ef4963mr583761ywk.9.1701382838407; Thu, 30 Nov 2023 14:20:38 -0800 (PST) MIME-Version: 1.0 References: <20231101215457.3935908-1-lhyatt@gmail.com> In-Reply-To: From: Lewis Hyatt Date: Thu, 30 Nov 2023 17:20:26 -0500 Message-ID: Subject: Re: [PATCH] preprocessor: Reinitialize frontend parser after loading a PCH [PR112319] To: Marek Polacek Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3035.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Nov 30, 2023 at 4:19=E2=80=AFPM Marek Polacek = wrote: > > On Wed, Nov 01, 2023 at 05:54:57PM -0400, Lewis Hyatt wrote: > > Hello- > > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112319 > > > > This is a one-line patch to fix the GCC 14 regression noted in the > > PR. Bootstrap + regtest all languages on x86-64 looks good. Is it OK pl= ease? > > Thanks! > > > > -Lewis > > > > -- >8 -- > > > > Since r14-2893, the frontend parser object needs to exist when running = in > > preprocess-only mode, because pragma_lex() is now called in that mode a= nd > > needs to make use of it. This is handled by calling c_init_preprocess()= at > > startup. If -fpch-preprocess is in effect (commonly, because of > > -save-temps), a PCH file may be loaded during preprocessing, in which > > case the parser will be destroyed, causing the issue noted in the > > PR. Resolve it by reinitializing the frontend parser after loading the = PCH. > > > > gcc/c-family/ChangeLog: > > > > PR pch/112319 > > * c-ppoutput.cc (cb_read_pch): Reinitialize the frontend parser > > "front-end" > > > after loading a PCH. > > > > gcc/testsuite/ChangeLog: > > > > PR pch/112319 > > * g++.dg/pch/pr112319.C: New test. > > * g++.dg/pch/pr112319.Hs: New test. > > * gcc.dg/pch/pr112319.c: New test. > > * gcc.dg/pch/pr112319.hs: New test. > > --- > > gcc/c-family/c-ppoutput.cc | 5 +++++ > > gcc/testsuite/g++.dg/pch/pr112319.C | 5 +++++ > > gcc/testsuite/g++.dg/pch/pr112319.Hs | 1 + > > gcc/testsuite/gcc.dg/pch/pr112319.c | 5 +++++ > > gcc/testsuite/gcc.dg/pch/pr112319.hs | 1 + > > 5 files changed, 17 insertions(+) > > create mode 100644 gcc/testsuite/g++.dg/pch/pr112319.C > > create mode 100644 gcc/testsuite/g++.dg/pch/pr112319.Hs > > create mode 100644 gcc/testsuite/gcc.dg/pch/pr112319.c > > create mode 100644 gcc/testsuite/gcc.dg/pch/pr112319.hs > > > > diff --git a/gcc/c-family/c-ppoutput.cc b/gcc/c-family/c-ppoutput.cc > > index 4aa2bef2c0f..4f973767976 100644 > > --- a/gcc/c-family/c-ppoutput.cc > > +++ b/gcc/c-family/c-ppoutput.cc > > @@ -862,4 +862,9 @@ cb_read_pch (cpp_reader *pfile, const char *name, > > > > fprintf (print.outf, "#pragma GCC pch_preprocess \"%s\"\n", name); > > print.src_line++; > > + > > + /* The process of reading the PCH has destroyed the frontend parser, > > "front-end" > > > + so ask the frontend to reinitialize it, in case we need it to > > "front end" > > (sorry to be overly pedantic...) > > Patch looks fine to me; please go ahead if you haven't pushed it already. > Thanks for the review! I did push it a few days ago as Jakub approved it... I will spell front end correctly next time :). -Lewis