aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2025-01-06 11:02:51 +0000
committerPhilip Herron <philip.herron@embecosm.com>2025-01-06 12:31:50 +0000
commit48aa71c3a7f5b8d9eb634c53e389c74dc29f7fe2 (patch)
tree22d96817b55a310d53ee61fc7a598ed631a8b4be /gcc
parenta62630f99093b253bf499d0c2da4765e197a5608 (diff)
downloadgcc-48aa71c3a7f5b8d9eb634c53e389c74dc29f7fe2.zip
gcc-48aa71c3a7f5b8d9eb634c53e389c74dc29f7fe2.tar.gz
gcc-48aa71c3a7f5b8d9eb634c53e389c74dc29f7fe2.tar.bz2
gccrs: fix ICE during HIR dump
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 <herron.philip@googlemail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/hir/rust-hir-dump.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc
index a6a8801..112e129 100644
--- a/gcc/rust/hir/rust-hir-dump.cc
+++ b/gcc/rust/hir/rust-hir-dump.cc
@@ -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
@@ -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 ());
@@ -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");
}