]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: macro-expand: Keep optional references to last_{def, invoc}
authorArthur Cohen <arthur.cohen@embecosm.com>
Thu, 3 Aug 2023 15:24:14 +0000 (17:24 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:00:29 +0000 (19:00 +0100)
commit1e288d66cb4f0a25a249c0c6dacc2efbf9e44dc8
tree8a8c17589d63dea70c4f6cc2143b9026cda8ee41
parentfa6bba6f220882a29b7a9e020c49043a3a7e869b
gccrs: macro-expand: Keep optional references to last_{def, invoc}

This avoids a use-after-free when reaching the recursion limit.

gcc/rust/ChangeLog:

* expand/rust-macro-expand.h: Keep optional references for last_def
and last_invoc.
* expand/rust-macro-expand.cc (MacroExpander::expand_invoc): Store
optional references.
* rust-session-manager.cc (Session::expansion): Use tl::optional's APIs
for better checking.
gcc/rust/expand/rust-macro-expand.cc
gcc/rust/expand/rust-macro-expand.h
gcc/rust/rust-session-manager.cc