Hello, While looking at PR preprocessor/64803, I noticed that builtin_macro was changing the location a token after it was been handed out by _cpp_lex_direct(). Use the combination of cpp_force_token_locations() and cpp_stop_forcing_token_locations() that are intended for exactly that use case.
Boostrapped and tested on x86_64-unknown-linux-gnu. libcpp/ChangeLog: * macro.c (builtin_macro): Use the combination of cpp_force_token_locations() and cpp_stop_forcing_token_locations() instead of modifying the location of the token after its initialization. OK to for trunk when stage 1 re-opens? Cheers, Signed-off-by: Dodji Seketeli <do...@redhat.com> --- libcpp/macro.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libcpp/macro.c b/libcpp/macro.c index 9571345..ca199ba 100644 --- a/libcpp/macro.c +++ b/libcpp/macro.c @@ -442,9 +442,12 @@ builtin_macro (cpp_reader *pfile, cpp_hashnode *node, source_location loc) /* Set pfile->cur_token as required by _cpp_lex_direct. */ pfile->cur_token = _cpp_temp_token (pfile); + /* force the location of the token emitted by _cpp_lex_direct() to + have the location LOC. */ + cpp_force_token_locations (pfile, &loc); cpp_token *token = _cpp_lex_direct (pfile); - /* We should point to the expansion point of the builtin macro. */ - token->src_loc = loc; + cpp_stop_forcing_token_locations (pfile); + if (pfile->context->tokens_kind == TOKENS_KIND_EXTENDED) { /* We are tracking tokens resulting from macro expansion. -- Dodji