Skip to content

Commit

Permalink
gccrs: fix ICE during HIR dump
Browse files Browse the repository at this point in the history
These hir nodes have optional expressions which need guarded

gcc/rust/ChangeLog:

	* hir/rust-hir-dump.cc (Dump::do_qualifiedpathtype): add guard
	(Dump::do_traitfunctiondecl): likewise
	(Dump::visit): likewise

Signed-off-by: Philip Herron <[email protected]>
  • Loading branch information
philberty committed Jan 6, 2025
1 parent a62630f commit 48aa71c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions gcc/rust/hir/rust-hir-dump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ Dump::do_qualifiedpathtype (QualifiedPathType &e)
do_mappings (e.get_mappings ());
visit_field ("type", e.get_type ());

visit_field ("trait", e.get_trait ());
if (e.has_as_clause ())
visit_field ("trait", e.get_trait ());
}

void
Expand Down Expand Up @@ -521,7 +522,8 @@ Dump::do_traitfunctiondecl (TraitFunctionDecl &e)
else
put_field ("function_params", "empty");

visit_field ("return_type", e.get_return_type ());
if (e.has_return_type ())
visit_field ("return_type", e.get_return_type ());

if (e.has_where_clause ())
put_field ("where_clause", e.get_where_clause ().as_string ());
Expand Down Expand Up @@ -1295,7 +1297,8 @@ Dump::visit (BreakExpr &e)
else
put_field ("label", "none");

visit_field ("break_expr ", e.get_expr ());
if (e.has_break_expr ())
visit_field ("break_expr ", e.get_expr ());

end ("BreakExpr");
}
Expand Down

0 comments on commit 48aa71c

Please sign in to comment.