]> git.ipfire.org Git - thirdparty/gcc.git/commit
preprocessor: Reinitialize frontend parser after loading a PCH [PR112319]
authorLewis Hyatt <lhyatt@gmail.com>
Wed, 1 Nov 2023 17:01:12 +0000 (13:01 -0400)
committerLewis Hyatt <lhyatt@gmail.com>
Fri, 24 Nov 2023 20:30:40 +0000 (15:30 -0500)
commit5d4abd9219dfa53b52b341255e99139bb6cad302
tree7a3fb35036556e11732b2f07f162caaea82e2afd
parent6eb1507107dee3e67e3a136e2917b93cdffba7c4
preprocessor: Reinitialize frontend parser after loading a PCH [PR112319]

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
gcc/testsuite/g++.dg/pch/pr112319.C [new file with mode: 0644]
gcc/testsuite/g++.dg/pch/pr112319.Hs [new file with mode: 0644]
gcc/testsuite/gcc.dg/pch/pr112319.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pch/pr112319.hs [new file with mode: 0644]