diff options
author | Philip Herron <herron.philip@googlemail.com> | 2024-11-25 20:16:42 +0000 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-21 12:33:03 +0100 |
commit | 42be99fc1ec19c84c03770bef776a7b615839f9a (patch) | |
tree | 0725d3ea68e8ea726662dcc1ba1ddc4388840f6e /gcc | |
parent | 42f94641509b3a1dd9b084cb4b7b50ba43d513e9 (diff) | |
download | gcc-42be99fc1ec19c84c03770bef776a7b615839f9a.zip gcc-42be99fc1ec19c84c03770bef776a7b615839f9a.tar.gz gcc-42be99fc1ec19c84c03770bef776a7b615839f9a.tar.bz2 |
gccrs: fix crash in hir dump with missing guards
gcc/rust/ChangeLog:
* hir/rust-hir-dump.cc (Dump::visit): add missing null checks
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/hir/rust-hir-dump.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc index 1b48b29..be785b9 100644 --- a/gcc/rust/hir/rust-hir-dump.cc +++ b/gcc/rust/hir/rust-hir-dump.cc @@ -1892,7 +1892,8 @@ Dump::visit (TraitItemFunc &e) do_traitfunctiondecl (e.get_decl ()); - visit_field ("block_expr", e.get_block_expr ()); + if (e.has_definition ()) + visit_field ("block_expr", e.get_block_expr ()); end ("TraitItemFunc"); } @@ -2007,7 +2008,8 @@ Dump::visit (ExternalFunctionItem &e) put_field ("has_variadics", std::to_string (e.is_variadic ())); - visit_field ("return_type", e.get_return_type ()); + if (e.has_return_type ()) + visit_field ("return_type", e.get_return_type ()); end ("ExternalFunctionItem"); } @@ -2254,8 +2256,10 @@ Dump::visit (LetStmt &e) put_field ("variable_pattern", e.get_pattern ().as_string ()); - visit_field ("type", e.get_type ()); - visit_field ("init_expr", e.get_init_expr ()); + if (e.has_type ()) + visit_field ("type", e.get_type ()); + if (e.has_init_expr ()) + visit_field ("init_expr", e.get_init_expr ()); end ("LetStmt"); } |