public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8842] gccrs: Parse normal functions with `self` parameter correctly
@ 2024-02-07 12:43 Arthur Cohen
0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-02-07 12:43 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:f89186f962421f6d972035fc4b4c20490e7b1c5b
commit r14-8842-gf89186f962421f6d972035fc4b4c20490e7b1c5b
Author: Kushal Pal <kushalpal109@gmail.com>
Date: Tue Jan 23 17:23:05 2024 +0530
gccrs: Parse normal functions with `self` parameter correctly
Fixes #2812
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_function):
Skip token if its a COMMA.
gcc/testsuite/ChangeLog:
* rust/compile/issue-2812.rs: New test.
Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
Diff:
---
gcc/rust/parse/rust-parse-impl.h | 4 ++--
gcc/testsuite/rust/compile/issue-2812.rs | 4 ++++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index c622ed7bc971..89e3731a8984 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -2946,8 +2946,8 @@ Parser<ManagedTokenSource>::parse_function (AST::Visibility vis,
&& initial_param.error () != ParseSelfError::NOT_SELF)
return nullptr;
- if (initial_param.has_value ())
- skip_token (COMMA);
+ if (initial_param.has_value () && lexer.peek_token ()->get_id () == COMMA)
+ skip_token ();
// parse function parameters (only if next token isn't right paren)
std::vector<std::unique_ptr<AST::Param>> function_params;
diff --git a/gcc/testsuite/rust/compile/issue-2812.rs b/gcc/testsuite/rust/compile/issue-2812.rs
new file mode 100644
index 000000000000..173259b12914
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-2812.rs
@@ -0,0 +1,4 @@
+// { dg-additional-options "-frust-compile-until=astvalidation" }
+fn foo_1(&self);
+fn foo_1(&mut self);
+fn foo_1(self);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-02-07 12:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-07 12:43 [gcc r14-8842] gccrs: Parse normal functions with `self` parameter correctly Arthur Cohen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).