gccrs: macros: Handle matchers properly in repetitions
authorArthur Cohen <arthur.cohen@embecosm.com>
Mon, 29 Aug 2022 10:51:33 +0000 (12:51 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 31 Jan 2023 13:16:49 +0000 (14:16 +0100)
commit1fed030c16519c0ebedb4cf0c6cebaa9ffa32e66
treeeb4c5bd6a99ad154f0d395260a59292acfafb157
parentf7014b28b81f43f62086d75222a9cfe7ca562b27
gccrs: macros: Handle matchers properly in repetitions

gcc/rust/ChangeLog:

* expand/rust-macro-expand.cc (MacroExpander::match_matcher): Handle
fragments differently based on whether or not we are currently trying
to match a matcher in a repetition context.
(MacroExpander::match_n_matches): Use new `in_repetition` argument
properly when calling `match_matcher`.
* expand/rust-macro-expand.h (MacroExpander::match_matcher): Allow
passing extra `in_repetition` bool argument

gcc/testsuite/ChangeLog:

* rust/compile/macro43.rs: New test.
gcc/rust/expand/rust-macro-expand.cc
gcc/rust/expand/rust-macro-expand.h
gcc/testsuite/rust/compile/macro43.rs [new file with mode: 0644]