Skip to content

Commit

Permalink
Use name resolver 2.0 for compiling break/continue
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc
	(CompileExpr::visit): Use name resolver 2.0 to lookup label
	definitions for break and continue statements when name
	resolution 2.0 is enabled.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
  • Loading branch information
powerboat9 authored and CohenArthur committed Oct 24, 2024
1 parent 120b234 commit b7eb4b0
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions gcc/rust/backend/rust-compile-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,24 @@ CompileExpr::visit (HIR::BreakExpr &expr)
if (expr.has_label ())
{
NodeId resolved_node_id = UNKNOWN_NODEID;
if (!ctx->get_resolver ()->lookup_resolved_label (
expr.get_label ().get_mappings ().get_nodeid (), &resolved_node_id))
if (flag_name_resolution_2_0)
{
auto &nr_ctx
= Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();

if (auto id
= nr_ctx.lookup (expr.get_label ().get_mappings ().get_nodeid ()))
resolved_node_id = *id;
}
else
{
NodeId tmp = UNKNOWN_NODEID;
if (ctx->get_resolver ()->lookup_resolved_label (
expr.get_label ().get_mappings ().get_nodeid (), &tmp))
resolved_node_id = tmp;
}

if (resolved_node_id == UNKNOWN_NODEID)
{
rust_error_at (
expr.get_label ().get_locus (),
Expand Down Expand Up @@ -799,8 +815,25 @@ CompileExpr::visit (HIR::ContinueExpr &expr)
if (expr.has_label ())
{
NodeId resolved_node_id = UNKNOWN_NODEID;
if (!ctx->get_resolver ()->lookup_resolved_label (
expr.get_label ().get_mappings ().get_nodeid (), &resolved_node_id))
if (flag_name_resolution_2_0)
{
auto &nr_ctx
= Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();

if (auto id
= nr_ctx.lookup (expr.get_label ().get_mappings ().get_nodeid ()))
resolved_node_id = *id;
}
else
{
NodeId tmp = UNKNOWN_NODEID;

if (ctx->get_resolver ()->lookup_resolved_label (
expr.get_label ().get_mappings ().get_nodeid (), &tmp))
resolved_node_id = tmp;
}

if (resolved_node_id == UNKNOWN_NODEID)
{
rust_error_at (
expr.get_label ().get_locus (),
Expand Down

0 comments on commit b7eb4b0

Please sign in to comment.