gcc/libcpp
Jakub Jelinek 37f373e974 libcpp: Diagnose #include after failed __has_include [PR80753]
As can be seen in the testcase, we don't diagnose #include/#include_next
of a non-existent header if __has_include/__has_include_next is done for
that header first.
The problem is that we normally error the first time some header is not
found, but in the _cpp_FFK_HAS_INCLUDE case obviously don't want to diagnose
it, just expand it to 0.  And libcpp caches both successful includes and
unsuccessful ones.

The following patch fixes that by remembering that we haven't diagnosed
error when using __has_include* on it, and diagnosing it when using the
cache entry in normal mode the first time.

I think _cpp_FFK_NORMAL is the only mode in which we normally diagnose
errors, for _cpp_FFK_PRE_INCLUDE that open_file_failed isn't reached
and for _cpp_FFK_FAKE neither.

2023-06-15  Jakub Jelinek  <jakub@redhat.com>

	PR preprocessor/80753
libcpp/
	* files.cc (struct _cpp_file): Add deferred_error bitfield.
	(_cpp_find_file): When finding a file in cache with deferred_error
	set in _cpp_FFK_NORMAL mode, call open_file_failed and clear the flag.
	Set deferred_error in _cpp_FFK_HAS_INCLUDE mode if open_file_failed
	hasn't been called.
gcc/testsuite/
	* c-c++-common/missing-header-5.c: New test.
2023-06-15 14:16:17 +02:00
..
include diagnostics: ensure that .sarif files are UTF-8 encoded [PR109098] 2023-03-24 20:52:34 -04:00
po Daily bump. 2023-05-10 00:17:49 +00:00
aclocal.m4
ChangeLog Daily bump. 2023-05-01 00:16:44 +00:00
ChangeLog.jit
charset.cc diagnostics: ensure that .sarif files are UTF-8 encoded [PR109098] 2023-03-24 20:52:34 -04:00
config.in build: re-configure 2 files 2022-11-21 09:03:35 +01:00
configure Revert "configure: Implement --enable-host-pie" 2022-11-22 21:10:31 -05:00
configure.ac Revert "configure: Implement --enable-host-pie" 2022-11-22 21:10:31 -05:00
directives.cc libcpp: Fix ICE on directive inside _Pragma() operator [PR67046] 2023-03-13 07:40:50 -04:00
errors.cc Update copyright years. 2023-01-16 11:52:17 +01:00
expr.cc Update copyright years. 2023-01-16 11:52:17 +01:00
files.cc libcpp: Diagnose #include after failed __has_include [PR80753] 2023-06-15 14:16:17 +02:00
generated_cpp_wcwidth.h libcpp: Update cpp_wcwidth() to Unicode 15 2023-03-13 07:40:50 -04:00
identifiers.cc Update copyright years. 2023-01-16 11:52:17 +01:00
init.cc Revert "[PATCH] libcpp: suppress builtin macro redefined warnings for __LINE__" 2023-04-30 17:12:19 -06:00
internal.h Update copyright years. 2023-01-16 11:52:17 +01:00
lex.cc Update copyright years. 2023-01-16 11:52:17 +01:00
line-map.cc Update copyright years. 2023-01-16 11:52:17 +01:00
location-example.txt
macro.cc Update copyright years. 2023-01-16 11:52:17 +01:00
Makefile.in Update copyright years. 2023-01-16 11:52:17 +01:00
makeucnid.cc libcpp: Update Unicode copyright years 2023-03-16 10:19:04 +01:00
makeuname2c.cc libcpp: Update Unicode copyright years 2023-03-16 10:19:04 +01:00
mkdeps.cc Update copyright years. 2023-01-16 11:52:17 +01:00
pch.cc Update copyright years. 2023-01-16 11:52:17 +01:00
symtab.cc Update copyright years. 2023-01-16 11:52:17 +01:00
system.h Update copyright years. 2023-01-16 11:52:17 +01:00
traditional.cc Update copyright years. 2023-01-16 11:52:17 +01:00
ucnid.h libcpp: Update Unicode copyright years 2023-03-16 10:19:04 +01:00
ucnid.tab Update copyright years. 2023-01-16 11:52:17 +01:00
uname2c.h libcpp: Update Unicode copyright years 2023-03-16 10:19:04 +01:00