gcc/libcpp
Lewis Hyatt 942497ad74 libcpp: Fix macro expansion for argument of __has_include [PR110558]
When the file name for a #include directive is the result of stringifying a
macro argument, libcpp needs to take some care to get the whitespace
correct; in particular stringify_arg() needs to see a CPP_PADDING token
between macro tokens so that it can figure out when to output space between
tokens. The CPP_PADDING tokens are not normally generated when handling a
preprocessor directive, but for #include-like directives, libcpp sets the
state variable pfile->state.directive_wants_padding to TRUE so that the
CPP_PADDING tokens will be output, and then everything works fine for
computed includes.

As the PR points out, things do not work fine for __has_include. Fix that by
setting the state variable the same as is done for #include.

libcpp/ChangeLog:

	PR preprocessor/110558
	* macro.cc (builtin_has_include): Set
	pfile->state.directive_wants_padding prior to lexing the
	file name, in case it comes from macro expansion.

gcc/testsuite/ChangeLog:

	PR preprocessor/110558
	* c-c++-common/cpp/has-include-2.c: New test.
	* c-c++-common/cpp/has-include-2.h: New test.
2024-03-14 07:33:02 -04:00
..
include c: Handle scoped attributes in __has*attribute and scoped attribute parsing changes in -std=c11 etc. modes [PR114007] 2024-02-22 19:32:02 +01:00
po Daily bump. 2024-02-22 00:18:58 +00:00
aclocal.m4 *: add modern gettext 2023-11-14 00:47:11 +01:00
ChangeLog Daily bump. 2024-02-23 00:16:46 +00:00
ChangeLog.jit
charset.cc libcpp: add function to check XID properties 2024-01-04 16:30:01 +01:00
combining-chars.inc diagnostics: add support for "text art" diagrams 2023-06-21 21:49:00 -04:00
config.in libcpp: configure: drop unused Valgrind detection 2023-11-24 16:13:56 +03:00
configure libcpp: configure: drop unused Valgrind detection 2023-11-24 16:13:56 +03:00
configure.ac libcpp: configure: drop unused Valgrind detection 2023-11-24 16:13:56 +03:00
directives.cc Update copyright years. 2024-01-03 12:19:35 +01:00
errors.cc Update copyright years. 2024-01-03 12:19:35 +01:00
expr.cc Update copyright years. 2024-01-03 12:19:35 +01:00
files.cc libcpp: Fix __has_include_next ICE in the last directory of the path [PR80755] 2024-03-14 07:33:02 -04:00
generated_cpp_wcwidth.h libcpp, contrib: Update to Unicode 15.1 2023-11-14 18:32:37 +01:00
identifiers.cc Update copyright years. 2024-01-03 12:19:35 +01:00
init.cc Update copyright years. 2024-01-03 12:19:35 +01:00
internal.h Update copyright years. 2024-01-03 12:19:35 +01:00
lex.cc c: Handle scoped attributes in __has*attribute and scoped attribute parsing changes in -std=c11 etc. modes [PR114007] 2024-02-22 19:32:02 +01:00
line-map.cc Update copyright years. 2024-01-03 12:19:35 +01:00
location-example.txt
macro.cc libcpp: Fix macro expansion for argument of __has_include [PR110558] 2024-03-14 07:33:02 -04:00
Makefile.in Update copyright years. 2024-01-03 12:19:35 +01:00
makeucnid.cc Update copyright years. 2024-01-03 12:19:35 +01:00
makeuname2c.cc Update copyright years. 2024-01-03 12:19:35 +01:00
mkdeps.cc Update copyright years. 2024-01-03 12:19:35 +01:00
pch.cc libcpp: Stabilize the location for macros restored after PCH load [PR105608] 2024-02-01 09:07:17 -05:00
printable-chars.inc diagnostics: add support for "text art" diagrams 2023-06-21 21:49:00 -04:00
symtab.cc Update copyright years. 2024-01-03 12:19:35 +01:00
system.h Update copyright years. 2024-01-03 12:19:35 +01:00
traditional.cc Update copyright years. 2024-01-03 12:19:35 +01:00
ucnid.h Update copyright years. 2024-01-03 12:19:35 +01:00
ucnid.tab Update copyright years. 2024-01-03 12:19:35 +01:00
uname2c.h Update copyright years. 2024-01-03 12:19:35 +01:00