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

Handle nested macro definition (resolver) #2537

Closed
wants to merge 1 commit into from

Conversation

P-E-P
Copy link
Member

@P-E-P P-E-P commented Aug 8, 2023

Fixes #2516

This PR clashes with #2541 we need to decide which one get merged. Per

// now do we need to keep mappings or something? or insert "uses" into our
// ForeverStack? can we do that? are mappings simpler?

This is still an early draft, I don't really know where I am going with this one. @CohenArthur could you give me more details about what you had in mind with this comment ?

@P-E-P P-E-P added this to the GCC 14 Stage 3 milestone Aug 8, 2023
@P-E-P P-E-P changed the title Handle nested macro definition Handle nested macro definition (resolver) Aug 10, 2023
@P-E-P P-E-P requested a review from CohenArthur August 10, 2023 15:16
We need to collect the early resolver's macros error to emit them at a
later stage after further expansion in order to retrieve macros defined
by other macro invocations.

gcc/rust/ChangeLog:

	* resolve/rust-early-name-resolver-2.0.cc (Early::visit):
	Collect error instead of emitting it.
	* resolve/rust-early-name-resolver-2.0.h (std::function<void):
	Add type definition for collection.
	* rust-session-manager.cc (Session::expansion): Collect errors
	while fixed point is not reached then emit remaining errors.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good starting point! Thank you for working on this :)

Comment on lines +138 to +141
collect_error ([&] () {
rust_error_at (invoc.get_locus (), ErrorCode::E0433,
"could not resolve macro invocation");
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use @MahadMuhammad's new Error constructor instead of this lambda, which should help clean up the code

@P-E-P
Copy link
Member Author

P-E-P commented Aug 28, 2023

We'll use mapping instead. Check #2541

@P-E-P P-E-P closed this Aug 28, 2023
@P-E-P P-E-P deleted the nested_macro_definition branch November 21, 2023 11:37
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.

Handle macro invocations expanding to new macro definitions
2 participants