public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marek Polacek <polacek@redhat.com>
To: Lewis Hyatt <lhyatt@gmail.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] preprocessor: Create the parser before handling command-line includes [PR115312]
Date: Thu, 27 Jun 2024 20:29:41 -0400	[thread overview]
Message-ID: <Zn4D9Y8xVw2sM63x@redhat.com> (raw)
In-Reply-To: <20240627210614.1251566-1-lhyatt@gmail.com>

On Thu, Jun 27, 2024 at 05:06:14PM -0400, Lewis Hyatt wrote:
> Hello-
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115312
> 
> This fixes a 14.1 regression with PCH for MinGW and other platforms that don't
> use stdc-predef.h. Bootstrap + regtest all languages on x86-64 Linux;
> bootstrap + regtest c,c++ on x86_64-w64-mingw32. Is it OK for 14 branch and
> master please? Thanks!
 
The patch looks good to me.  I think you can push it next week if there
are no objections.

Reviewed-by: Marek Polacek <polacek@redhat.com>

> -- >8 --
> 
> Since r14-2893, we create a parser object in preprocess-only mode for the
> purpose of parsing #pragma while preprocessing. The parser object was
> formerly created after calling c_finish_options(), which leads to problems
> on platforms that don't use stdc-predef.h (such as MinGW, as reported in
> the PR). On such platforms, the call to c_finish_options() will process
> the first command-line-specified include file. If that includes a PCH, then
> c-ppoutput.cc will encounter a state it did not anticipate. Fix it by
> creating the parser prior to calling c_finish_options().
> 
> gcc/c-family/ChangeLog:
> 
> 	PR pch/115312
> 	* c-opts.cc (c_common_init): Call c_init_preprocess() before
> 	c_finish_options() so that a parser is available to process any
> 	includes specified on the command line.
> 
> gcc/testsuite/ChangeLog:
> 
> 	PR pch/115312
> 	* g++.dg/pch/pr115312.C: New test.
> 	* g++.dg/pch/pr115312.Hs: New test.
> ---
>  gcc/c-family/c-opts.cc               | 2 +-
>  gcc/testsuite/g++.dg/pch/pr115312.C  | 2 ++
>  gcc/testsuite/g++.dg/pch/pr115312.Hs | 1 +
>  3 files changed, 4 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/g++.dg/pch/pr115312.C
>  create mode 100644 gcc/testsuite/g++.dg/pch/pr115312.Hs
> 
> diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
> index 33114f13c8d..b7789b707e6 100644
> --- a/gcc/c-family/c-opts.cc
> +++ b/gcc/c-family/c-opts.cc
> @@ -1296,8 +1296,8 @@ c_common_init (void)
>  
>    if (flag_preprocess_only)
>      {
> -      c_finish_options ();
>        c_init_preprocess ();
> +      c_finish_options ();
>        preprocess_file (parse_in);
>        return false;
>      }
> diff --git a/gcc/testsuite/g++.dg/pch/pr115312.C b/gcc/testsuite/g++.dg/pch/pr115312.C
> new file mode 100644
> index 00000000000..9074ad4a5ad
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/pch/pr115312.C
> @@ -0,0 +1,2 @@
> +/* { dg-additional-options "-include pr115312.H -save-temps" } */
> +#error "suppress PCH assembly comparison, which does not work with -save-temps" /* { dg-error "." } */
> diff --git a/gcc/testsuite/g++.dg/pch/pr115312.Hs b/gcc/testsuite/g++.dg/pch/pr115312.Hs
> new file mode 100644
> index 00000000000..6e7c6bcac2f
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/pch/pr115312.Hs
> @@ -0,0 +1 @@
> +// This space intentionally left blank.
> 

Marek


      reply	other threads:[~2024-06-28  0:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-27 21:06 Lewis Hyatt
2024-06-28  0:29 ` Marek Polacek [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zn4D9Y8xVw2sM63x@redhat.com \
    --to=polacek@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=lhyatt@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).