From patchwork Wed Nov 1 21:54:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lewis Hyatt X-Patchwork-Id: 160696 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:abcd:0:b0:403:3b70:6f57 with SMTP id f13csp731524vqx; Wed, 1 Nov 2023 14:55:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFewYs0jrlMWtww0YmHolwTe1v4HrlsucMhGZEyXb5KIvsG4XAnGjfkmyhFgmwbFTIxFtje X-Received: by 2002:ac8:5991:0:b0:40f:f0e0:a008 with SMTP id e17-20020ac85991000000b0040ff0e0a008mr23028229qte.53.1698875740455; Wed, 01 Nov 2023 14:55:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698875740; cv=pass; d=google.com; s=arc-20160816; b=twyBfWtuf/NwhS9R0q8W+5kfnAV3kvcYz0hqDagx0HxQPb6jrz5VRkvWZrt0KeuPh8 J5Qp8NPnlgCXtEQENG4NZbBnMrHFHR+PUlL6guXuqhwwqBtXMQIcIPObCVYkHW1jUMc5 OBDypE4s0hWEgUobTMQQESveIiYjT+Zx5INaksJcsMipWgkLvHmW42hzAifYDC7tHY/X Vqrwip1+FEnITZJ53ILAAkKu/bMIQtvFjB5CzbWexXkOpMQoKrmsK81/z5nfmQXgvhBr v1P3QQJFt3D6po4wrmojVutD5CnBjY5083Vws57s6U6nr5Rq6Zje9ftgTOtdekpEgihM f5IA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=tLYWufyPzb8izT+uY5MKrywfLKGbXAN7p4o16Sw6lkw=; fh=nfBkqenZlXK8N3U+CwE1Ju+aGndKKEqCeWWaqIiAkr0=; b=J0NVnZcB9fzsAJlCoAsQYavHB4s8xdSv8KYPgNR0vdV4CfA6a5nNCf9c4M4yhY45pL /zX5xARvvqsibYvRE4JeKmAw3pxH6IOA6pQo3hQqemb09aTDnlBoiUcCmCU6Y8+5Ty6N G8e0JdKlVuSYwDDSqRijZWI9S/nG/KdcJfSHhveIo5oQPxTX/cQgUeKgSAAgexPZVzih MXLBfFTi6VQfB6XQxDghbjl3VhTnrwgVSe0ULHS08GrNyQSvPBXSL66Jg0kZuZNGJzEJ h6JtDfFdNLFXJjr3SJqqOT/p7i5yc0zT8a61H2IWbxVPkeHZIfuowqqgkgylGNEdUz4v Lyng== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jUUnmbX4; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id y16-20020a05622a005000b004181b8ae8edsi3362843qtw.246.2023.11.01.14.55.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 14:55:40 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jUUnmbX4; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 384BA3858CDB for ; Wed, 1 Nov 2023 21:55:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-vk1-xa35.google.com (mail-vk1-xa35.google.com [IPv6:2607:f8b0:4864:20::a35]) by sourceware.org (Postfix) with ESMTPS id 82EA13858D28 for ; Wed, 1 Nov 2023 21:55:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 82EA13858D28 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 82EA13858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::a35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698875713; cv=none; b=XlHc4lGpSayE7xPP7JyMH8AzfloPRkcWEaHBo2zrHdUqxewhdNaFdqLvqiMiGD/b3h5Q72olrDHOBsXQEt3cv0oPejmAyE6Ubf4WFe0K7BFUv+h8UDbiXNVpFPQutHxNtjR8orDTXqjFfs/pa4vo4+1+NGkVBVBFPWTVfkuit0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698875713; c=relaxed/simple; bh=HrY3NyXDTVzodVoXWNdy/IJCtJqRkP8MRFOA3Vg7PGU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=sScEdy8lFItr+WWqO9lgHfX3T5dFybwUBrNSyc0lN5/kHNR2zmP08Q+S40ZKAwN9ukvjnKfSqqyJ1DvpDivHLu1KyqNW6XFxRPIN70WyEyc4tJJ0IntFQC22qwo90xQ/24oqNxdT/EyolVK7u1I1Hg5KXnKl+BpLycGOQfvwHQA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-vk1-xa35.google.com with SMTP id 71dfb90a1353d-4a40c8dd9b0so137528e0c.0 for ; Wed, 01 Nov 2023 14:55:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698875702; x=1699480502; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tLYWufyPzb8izT+uY5MKrywfLKGbXAN7p4o16Sw6lkw=; b=jUUnmbX4La8TreBCev3AFc2BvTWLoWSzFntD//cHkfjn2nXznHfnr4+k1JVHChRns2 kR9tDCOjD12G7XHVdVkg2JatiP5PxpKcXJLF5SLRssFTi2iAbHW5Uzu2qhQgjbm7QtOj YDkqyM5BICcf+XXxv+p0+S3HVYHQyfdq3Os3hos2SiWSnXrJs+2g1501oqBbaB7gRfHI 7gSQ0oUfj/MS3uJtZpoYlNaPNh6LbwFNYFtzQAbtr+SkDJFVuB3iJ7LmOar2YQ9wL4hY syVvoyvvSG1YHjQpzV/jL8wwdDt6tAzZ3lfSDxnJ2Y7Cu7hjadd0SN2LwSUPGl7Xe/nQ Ongg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698875702; x=1699480502; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tLYWufyPzb8izT+uY5MKrywfLKGbXAN7p4o16Sw6lkw=; b=pu8KRLVT88tFOWKL53wt2rEeuGtRaZKz7SYegFI5hwjeAZ+6EJnmTHxYluF6gK4sZl g98MKHQSd61fEKfdmXe+0VxYo+NkCbSxfFMT7nmdCJa5mQgCvFZCR1X5NJeXJmq2B3L7 Ucn2BVcsUmp5LK1K1KgbhZeBQJN1oroJTlRXykta8HlblKhzlx1ASc5rEROvpVZqEMct hPOWOUub238dDJ1Fj0Dtl1t/kq+G8mpOM05b8iGHLBORWzttedgVFytX3e1B25qaQbxX tnnGQcP72iDDDxvGPgyTwIGirCoJTdnENVzxR32i76X8mhM0u/NLOvYKy2YojTSLqah9 4g0w== X-Gm-Message-State: AOJu0YxIlj6fYuxOTuMVszQm8moFW7K9rhuwGummjjKNzx9qCnbgok0W 2U+4kn5ja5/w1I0EeYVMkLEhxDE0GPI= X-Received: by 2002:a05:6122:609:b0:4ab:cfc6:5291 with SMTP id u9-20020a056122060900b004abcfc65291mr637741vkp.16.1698875702039; Wed, 01 Nov 2023 14:55:02 -0700 (PDT) Received: from localhost.localdomain (96-67-140-173-static.hfc.comcastbusiness.net. [96.67.140.173]) by smtp.gmail.com with ESMTPSA id qp9-20020a05620a388900b0076eee688a95sm1828073qkn.0.2023.11.01.14.55.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 14:55:01 -0700 (PDT) From: Lewis Hyatt To: gcc-patches@gcc.gnu.org Cc: Lewis Hyatt Subject: [PATCH] preprocessor: Reinitialize frontend parser after loading a PCH [PR112319] Date: Wed, 1 Nov 2023 17:54:57 -0400 Message-Id: <20231101215457.3935908-1-lhyatt@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3038.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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781400328154534349 X-GMAIL-MSGID: 1781400328154534349 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 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, + so ask the frontend to reinitialize it, in case we need it to + 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. */