Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix token lexed as a float literal #2694

Merged
merged 2 commits into from
Nov 6, 2023

Conversation

P-E-P
Copy link
Member

@P-E-P P-E-P commented Oct 17, 2023

The lexer cannot distinguish the difference between a float literal and a tuple index in some cases. This means we should fix this while parsing depending on the context.

Fixes #2659

@P-E-P P-E-P added this to the GCC 14.1 release milestone Oct 17, 2023
@P-E-P P-E-P self-assigned this Oct 17, 2023
@P-E-P P-E-P marked this pull request as ready for review October 17, 2023 11:43
@P-E-P P-E-P force-pushed the fix-tuple-index-parsing branch 2 times, most recently from 683836e to afbd2a4 Compare October 17, 2023 12:31
The lexer cannot distinguish the difference between a float literal and a
tuple index in some cases. This means we should fix this while parsing
depending on the context.

gcc/rust/ChangeLog:

	* expand/rust-macro-invoc-lexer.cc (MacroInvocLexer::split_current_token):
	Add implementation for multiple token split.
	* expand/rust-macro-invoc-lexer.h: Add function prototype.
	* expand/rust-proc-macro-invoc-lexer.cc (ProcMacroInvocLexer::split_current_token):
	Add implementation for 2+ token split for procedural macros.
	* expand/rust-proc-macro-invoc-lexer.h: Add function prototype.
	* lex/rust-lex.cc (Lexer::split_current_token): Add function to split a
	token in multiple other tokens.
	* lex/rust-lex.h: Add function prototype for split_current_token.
	* parse/rust-parse-impl.h (Parser::left_denotation): Handle float tuple
	index identified as a float literal.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
Add a new regression test in order to highlight the fix for Rust-GCC#2659.

gcc/testsuite/ChangeLog:

	* rust/compile/not_a_float_literal_tuple_index.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
@P-E-P P-E-P mentioned this pull request Oct 31, 2023
@CohenArthur CohenArthur added this pull request to the merge queue Nov 6, 2023
Merged via the queue into Rust-GCC:master with commit e009d3d Nov 6, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Tuple index not parsed correctly
2 participants