libcpp: Fix up ICE with __VA_OPT__ [PR125048]

The following testcase ICEs, because we call linemap_enter_macro
and remember what it returned and then in a loop sometimes call
vaopt_state::update (src) which can call expand_arg which under the
hood can reallocate the pfile->line_table->info_macro.maps array.
As linemap_enter_macro returns a pointer into that array, if the
array is reallocated, we then dereference the freed memory.

The following patch fixes it by remembering the offset into the
pfile->line_table->info_macro.maps array and when we could have called
expand_arg, updates the map variable so that it is correct even after
possible reallocation.

2026-04-28  Jakub Jelinek  <jakub@redhat.com>

	PR preprocessor/125048
	* macro.cc (replace_args): Remember the position of map
	in the pfile->line_table->info_macro.maps array and if vostate
	is DROP, recompute map pointer as expand_arg call could have
	reallocated the pfile->line_table->info_macro.maps array.

	* c-c++-common/cpp/va-opt-11.c: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 7b87f41690d46b869c21d0d0537b766698da3827)
2 files changed