Skip to content

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 requested a review from CohenArthur October 17, 2023 11:31
@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
P-E-P added 2 commits October 23, 2023 14:19
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 force-pushed the fix-tuple-index-parsing branch from afbd2a4 to 8f043f9 Compare October 23, 2023 12:19
@P-E-P P-E-P requested a review from CohenArthur October 23, 2023 12:21
@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
@P-E-P P-E-P deleted the fix-tuple-index-parsing branch March 18, 2025 13:49
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