gcc/libcpp
Jakub Jelinek ac5fd364f0 libcpp: Fix up #__VA_OPT__ handling [PR103415]
stringify_arg uses pfile->u_buff to create the string literal.
Unfortunately, paste_tokens -> _cpp_lex_direct -> lex_number -> _cpp_unaligned_alloc
can in some cases use pfile->u_buff too, which results in losing everything
prepared for the string literal until the token pasting.

The following patch fixes that by not calling paste_token during the
construction of the string literal, but doing that before.  All the tokens
we are processing have been pushed into a token buffer using
tokens_buff_add_token so it is fine if we paste some of them in that buffer
(successful pasting creates a new token in that buffer), move following
tokens if any to make it contiguous, pop (throw away) the extra tokens at
the end and then do stringify_arg.

Also, paste_tokens now copies over PREV_WHITE and PREV_FALLTHROUGH flags
from the original lhs token to the replacement token.  Copying that way
the PREV_WHITE flag is needed for the #__VA_OPT__ handling and copying
over PREV_FALLTHROUGH fixes the new Wimplicit-fallthrough-38.c test.

2021-12-01  Jakub Jelinek  <jakub@redhat.com>

	PR preprocessor/103415
libcpp/
	* macro.c (stringify_arg): Remove va_opt argument and va_opt handling.
	(paste_tokens): On successful paste or in PREV_WHITE and
	PREV_FALLTHROUGH flags from the *plhs token to the new token.
	(replace_args): Adjust stringify_arg callers.  For #__VA_OPT__,
	perform token pasting in a separate loop before stringify_arg call.
gcc/testsuite/
	* c-c++-common/cpp/va-opt-8.c: New test.
	* c-c++-common/Wimplicit-fallthrough-38.c: New test.
2021-12-01 10:07:59 +01:00
..
include
po
aclocal.m4
ChangeLog Daily bump. 2021-12-01 00:17:04 +00:00
ChangeLog.jit
charset.c Remove more stray returns and gcc_unreachable ()s 2021-11-30 15:05:12 +01:00
config.in
configure Make etags path used by build system configurable 2021-11-29 13:24:12 -05:00
configure.ac Make etags path used by build system configurable 2021-11-29 13:24:12 -05:00
directives.c
errors.c
expr.c
files.c
generated_cpp_wcwidth.h
identifiers.c
init.c libcpp: Enable P1949R7 for C++11 and up as it was a DR [PR100977] 2021-11-30 09:50:52 +01:00
internal.h libcpp: Fix _Pragma stringification [PR103165] 2021-11-22 22:29:20 +01:00
lex.c libcpp: Use [[likely]] conditionally 2021-11-22 21:43:38 -05:00
line-map.c
location-example.txt
macro.c libcpp: Fix up #__VA_OPT__ handling [PR103415] 2021-12-01 10:07:59 +01:00
Makefile.in Make etags path used by build system configurable 2021-11-29 13:24:12 -05:00
makeucnid.c
mkdeps.c
pch.c
symtab.c
system.h libcpp: Fix ATTR_LIKELY definition PR preprocessor/103355 2021-11-23 16:06:42 +00:00
traditional.c
ucnid.h
ucnid.tab