From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id DBF133858417 for ; Thu, 30 Nov 2023 21:19:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DBF133858417 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DBF133858417 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701379194; cv=none; b=QMmrnOxS3hWA029HGNvnGg4EByZSgcLpTXMcr39D0XYGuju7/gY5cTdFvIxIx9mZCX685F4m+252dgCInl6ZL/2RIcMRk99EWHz0JCQ/t6/5xAC0SwW1oOy1J3tAT1Vzz8QhJL7jDc5EVXvoudbdfSdqbReIipDA99j1sxFZZUQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701379194; c=relaxed/simple; bh=tY9Mwy/1FaCBumXghIcz62Abo9Pq9NqXPvlnBWm+jp8=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=hKchf80BAPVtKgq7P71FuXOOnYDufg/iJqsP+sdTHZKwagpuK69gSAHiqeNR90Iotd8LEhH7vrLnuw580pcM+vKGFod+YuNhxJegu4yWCWuhfdLYiloQpim+EH3Io4/nW4AnS9VzHqRv2eNPWQJPmU1Wq4V9zuGE5E9KQtIxC+8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701379192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iJ4Efyn7cIAOQnf4S681cRubnykUk7Z12Mgi4g+D92Y=; b=Ks1ZeENkq3v+ASgA8XzRdNo1aC38a/X+6ZfSoTqqx2v2CHOWXuH3ALefKh193BXuLZH8AH L5t6lDLU3CpCsdJMZeWENUzgdIbjEPZ9Ovj7ArzIN1ZF3jjuK9QdSCnNDnB+cTyMGtuPb6 BUDXvL4jBb2QXm9PIdtkBUoynyB9lFU= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-AMTDwZZBMYunPGiRU_PGCQ-1; Thu, 30 Nov 2023 16:19:50 -0500 X-MC-Unique: AMTDwZZBMYunPGiRU_PGCQ-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-67a16e9eedbso18791056d6.0 for ; Thu, 30 Nov 2023 13:19:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701379190; x=1701983990; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iJ4Efyn7cIAOQnf4S681cRubnykUk7Z12Mgi4g+D92Y=; b=c2X0C3HdwxJegmsM/fy35lCav8HCOJvG4wVymBld3RdZc2iwdqSiixBZJTTBtfoUbY pYeLjcItQ74tcgG+j9BKwZURapVsyKiDYXCiliWnBkeDLdEAxy9Z57tmEWh05QqAH3aN a20X365q5hLj/CdyC0VawUxZ+T2gOcrocvafN7SE5KMdiRs81XPPd4h0axnO8mLVRvYG SanB0JfpMoq1HfZb55rupFDVwaFGnWbfHroNEhEbjqZhgT8XS+FHLalpW+1Y4J+bwTaq ZBN+3jLab6bVcYYrfKPdfGUs731IfNumfnCLsMni+4dF1wTRcd2nKJbrX1S8yvOExY/v g3lg== X-Gm-Message-State: AOJu0Yw4Hyv6jmrQvYQRDNdltL4w44BwTwBw/RFHNS1WpO4fbLLDE/Dx u0SHmg+IGODhx6YrY8a/28FxlCj0DCVOoMI4OLOjMLf7vuW94hTpkKilPB1nOJ1rCKN9L0Tsv74 CSz3n+0i0sKgfufBk5bCHodEQcw== X-Received: by 2002:a0c:ef88:0:b0:67a:16fc:66f0 with SMTP id w8-20020a0cef88000000b0067a16fc66f0mr22946889qvr.53.1701379189920; Thu, 30 Nov 2023 13:19:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHDb8kvzW6jVyi3fFhenV7LVxIS7nckOaZ34Of3HwlC+OxKQ2T4m7rb0qoRvfu0O4wqGcljg== X-Received: by 2002:a0c:ef88:0:b0:67a:16fc:66f0 with SMTP id w8-20020a0cef88000000b0067a16fc66f0mr22946874qvr.53.1701379189604; Thu, 30 Nov 2023 13:19:49 -0800 (PST) Received: from redhat.com (2603-7000-9500-34a5-0000-0000-0000-1db4.res6.spectrum.com. [2603:7000:9500:34a5::1db4]) by smtp.gmail.com with ESMTPSA id q20-20020a0cf5d4000000b0067a4452d459sm840948qvm.116.2023.11.30.13.19.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 13:19:49 -0800 (PST) Date: Thu, 30 Nov 2023 16:19:47 -0500 From: Marek Polacek To: Lewis Hyatt Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] preprocessor: Reinitialize frontend parser after loading a PCH [PR112319] Message-ID: References: <20231101215457.3935908-1-lhyatt@gmail.com> MIME-Version: 1.0 In-Reply-To: <20231101215457.3935908-1-lhyatt@gmail.com> User-Agent: Mutt/2.2.9 (2022-11-12) X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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 Wed, Nov 01, 2023 at 05:54:57PM -0400, Lewis Hyatt wrote: > Hello- > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112319 > > 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 please? > 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 and > 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. > + process any #pragma directives encountered while preprocessing. */ > + c_init_preprocess (); > } > diff --git a/gcc/testsuite/g++.dg/pch/pr112319.C b/gcc/testsuite/g++.dg/pch/pr112319.C > new file mode 100644 > index 00000000000..9e0457e8aec > --- /dev/null > +++ b/gcc/testsuite/g++.dg/pch/pr112319.C > @@ -0,0 +1,5 @@ > +/* { dg-additional-options "-Wpragmas -save-temps" } */ > +#include "pr112319.H" > +#pragma GCC diagnostic error "-Wpragmas" > +#pragma GCC diagnostic ignored "oops" /* { dg-error "oops" } */ > +/* { dg-regexp {[^[:space:]]*: some warnings being treated as errors} } */ > diff --git a/gcc/testsuite/g++.dg/pch/pr112319.Hs b/gcc/testsuite/g++.dg/pch/pr112319.Hs > new file mode 100644 > index 00000000000..3b6178bfae0 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/pch/pr112319.Hs > @@ -0,0 +1 @@ > +/* This space intentionally left blank. */ > diff --git a/gcc/testsuite/gcc.dg/pch/pr112319.c b/gcc/testsuite/gcc.dg/pch/pr112319.c > new file mode 100644 > index 00000000000..043881463c5 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/pch/pr112319.c > @@ -0,0 +1,5 @@ > +/* { dg-additional-options "-Wpragmas -save-temps" } */ > +#include "pr112319.h" > +#pragma GCC diagnostic error "-Wpragmas" > +#pragma GCC diagnostic ignored "oops" /* { dg-error "oops" } */ > +/* { dg-regexp {[^[:space:]]*: some warnings being treated as errors} } */ > diff --git a/gcc/testsuite/gcc.dg/pch/pr112319.hs b/gcc/testsuite/gcc.dg/pch/pr112319.hs > new file mode 100644 > index 00000000000..3b6178bfae0 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/pch/pr112319.hs > @@ -0,0 +1 @@ > +/* This space intentionally left blank. */ > Marek