aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2025-05-09 22:17:55 -0400
committerArthur Cohen <arthur.cohen@embecosm.com>2025-08-05 16:36:42 +0200
commit449378d8435c3f9c1986c3eb61a40ba8e90c542c (patch)
tree65160c125ab125fef583a1346a4b31261a91ef32 /gcc
parent8e454ab6e18966dd205d8111faec2b709bcbc666 (diff)
downloadgcc-449378d8435c3f9c1986c3eb61a40ba8e90c542c.zip
gcc-449378d8435c3f9c1986c3eb61a40ba8e90c542c.tar.gz
gcc-449378d8435c3f9c1986c3eb61a40ba8e90c542c.tar.bz2
gccrs: Fix Attr metavariable binding
gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_attr_input): Handle more delimeter tokens and the END_OF_FILE token. (Parser::skip_after_end_attribute): Handle the END_OF_FILE token. gcc/testsuite/ChangeLog: * rust/compile/macros/mbe/meta-param.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/parse/rust-parse-impl.h5
-rw-r--r--gcc/testsuite/rust/compile/macros/mbe/meta-param.rs7
2 files changed, 11 insertions, 1 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index a0af8a3..3a2fcd2 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -877,7 +877,10 @@ Parser<ManagedTokenSource>::parse_attr_input ()
return attr_input_lit;
}
break;
+ case RIGHT_PAREN:
case RIGHT_SQUARE:
+ case RIGHT_CURLY:
+ case END_OF_FILE:
// means AttrInput is missing, which is allowed
return nullptr;
default:
@@ -11911,7 +11914,7 @@ Parser<ManagedTokenSource>::skip_after_end_attribute ()
{
const_TokenPtr t = lexer.peek_token ();
- while (t->get_id () != RIGHT_SQUARE)
+ while (t->get_id () != RIGHT_SQUARE && t->get_id () != END_OF_FILE)
{
lexer.skip_token ();
t = lexer.peek_token ();
diff --git a/gcc/testsuite/rust/compile/macros/mbe/meta-param.rs b/gcc/testsuite/rust/compile/macros/mbe/meta-param.rs
new file mode 100644
index 0000000..ed6e100
--- /dev/null
+++ b/gcc/testsuite/rust/compile/macros/mbe/meta-param.rs
@@ -0,0 +1,7 @@
+macro_rules! foo {
+ ($x:meta) => {0}
+}
+
+pub fn main() -> i32 {
+ foo!(Clone)
+}