]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Fix crash in hir dump as labels are optional
authorPhilip Herron <herron.philip@googlemail.com>
Wed, 16 Apr 2025 16:00:28 +0000 (17:00 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 28 Apr 2025 14:18:53 +0000 (16:18 +0200)
gcc/rust/ChangeLog:

* hir/rust-hir-dump.cc (Dump::visit): add guard for optional label

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/hir/rust-hir-dump.cc

index dafa8236ba10a9ab7fb2efaa783681da9155865a..16fce6be28e659758b5fa1634a9db629cf49f2c7 100644 (file)
@@ -1284,7 +1284,9 @@ Dump::visit (BlockExpr &e)
   do_expr (e);
   do_inner_attrs (e);
   put_field ("tail_reachable", std::to_string (e.is_tail_reachable ()));
-  put_field ("label", e.get_label ().as_string ());
+
+  if (e.has_label ())
+    put_field ("label", e.get_label ().as_string ());
 
   visit_collection ("statements", e.get_statements ());