public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/rust/master] Fix lexing of empty comments continuing till next line
Date: Mon, 13 Jun 2022 18:15:00 +0000 (GMT) [thread overview]
Message-ID: <20220613181500.334DB38582AF@sourceware.org> (raw)
https://gcc.gnu.org/g:11493cccd7e7fc5ea31e37581323f85eca58ca0c
commit 11493cccd7e7fc5ea31e37581323f85eca58ca0c
Author: Nirmal Patel <nirmal@nirmal.dev>
Date: Sun Jun 12 19:23:30 2022 -0400
Fix lexing of empty comments continuing till next line
Empty comments (comments without any characters including spaces after
//) had a bug during lexing. The lexer did not recheck the current
character after skipping / characters. When there was no character after
//, the lexer skipped the next newline character. This caused lexer to
count the next line as a part of the comment to. This commit fixes this
bug by rechecking current character after skipping two / characters.
Signed-off-by: Nirmal Patel <nirmal@nirmal.dev>
Diff:
---
gcc/rust/lex/rust-lex.cc | 1 +
| 7 +++++++
2 files changed, 8 insertions(+)
diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc
index 023b67651b7..9e0595b02fb 100644
--- a/gcc/rust/lex/rust-lex.cc
+++ b/gcc/rust/lex/rust-lex.cc
@@ -489,6 +489,7 @@ Lexer::build_token ()
// (but not an inner or outer doc comment)
skip_input ();
current_column += 2;
+ current_char = peek_input ();
// basically ignore until line finishes
while (current_char != '\n' && current_char != EOF)
--git a/gcc/testsuite/rust/compile/empty_comment_before_match.rs b/gcc/testsuite/rust/compile/empty_comment_before_match.rs
new file mode 100644
index 00000000000..3d344d3e758
--- /dev/null
+++ b/gcc/testsuite/rust/compile/empty_comment_before_match.rs
@@ -0,0 +1,7 @@
+fn foo (x: i8) -> i32 { // { dg-warning "function is never used" }
+ //
+ match x {
+ 1 => { return 1; }
+ _ => { return 0; }
+ }
+}
reply other threads:[~2022-06-13 18:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220613181500.334DB38582AF@sourceware.org \
--to=tschwinge@gcc.gnu.org \
--cc=gcc-cvs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).