]> gcc.gnu.org Git - gcc.git/commit
c-family: Let libcpp know when the compilation is for a PCH [PR9471]
authorLewis Hyatt <lhyatt@gmail.com>
Fri, 10 Nov 2023 16:10:18 +0000 (11:10 -0500)
committerLewis Hyatt <lhyatt@gmail.com>
Tue, 14 Nov 2023 22:50:42 +0000 (17:50 -0500)
commit9938645fcf914ec2a3fa8137cf1456ad4af5f77c
tree8875498bc2df0eaeb62610361d15514c82fbd6cd
parentf71352c71d78ac977ea0e71a6900699a8cf09219
c-family: Let libcpp know when the compilation is for a PCH [PR9471]

libcpp will generate diagnostics when it encounters things in the main file
that only belong in a header file, such as `#pragma once' or `#pragma GCC
system_header'. But sometimes the main file is a header file that is just
being compiled separately, e.g. to produce a C++ module or a PCH, in which
case such diagnostics should be suppressed. libcpp already has an interface
to request that, so make use of it in the C frontends to prevent libcpp from
issuing unwanted diagnostics when compiling a PCH.

gcc/c-family/ChangeLog:

PR pch/9471
PR pch/47857
* c-opts.cc (c_common_post_options): Set cpp_opts->main_search
so libcpp knows it is compiling a header file separately.

gcc/testsuite/ChangeLog:

PR pch/9471
PR pch/47857
* g++.dg/pch/main-file-warnings.C: New test.
* g++.dg/pch/main-file-warnings.Hs: New test.
* gcc.dg/pch/main-file-warnings.c: New test.
* gcc.dg/pch/main-file-warnings.hs: New test.
gcc/c-family/c-opts.cc
gcc/testsuite/g++.dg/pch/main-file-warnings.C [new file with mode: 0644]
gcc/testsuite/g++.dg/pch/main-file-warnings.Hs [new file with mode: 0644]
gcc/testsuite/gcc.dg/pch/main-file-warnings.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pch/main-file-warnings.hs [new file with mode: 0644]
This page took 0.065571 seconds and 6 git commands to generate.