aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/hir
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2025-04-04 16:35:13 +0100
committerPhilip Herron <philip.herron@embecosm.com>2025-04-16 09:04:47 +0000
commit5ac41dce35b947f5d1f904b39958ebf6f1b538cf (patch)
tree3612e5900e004cf5f97e38857b7fc694cab8c7a7 /gcc/rust/hir
parentdaf5dbc0272d57b772d579233268545c3a485e18 (diff)
downloadgcc-5ac41dce35b947f5d1f904b39958ebf6f1b538cf.zip
gcc-5ac41dce35b947f5d1f904b39958ebf6f1b538cf.tar.gz
gcc-5ac41dce35b947f5d1f904b39958ebf6f1b538cf.tar.bz2
gccrs: Fix segv in unsafe chcker
Trait constants were missing type resolution step, this adds that as if it was a normal constant. The unsafe checker was missing a null check. Fixes Rust-GCC#3612 gcc/rust/ChangeLog: * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): add null check * hir/tree/rust-hir-item.h: add has_type helper * typecheck/rust-hir-trait-resolve.cc (TraitItemReference::resolve_item): add missing type checking gcc/testsuite/ChangeLog: * rust/compile/issue-3612.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/hir')
-rw-r--r--gcc/rust/hir/tree/rust-hir-item.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h
index f45d743..41ba38c 100644
--- a/gcc/rust/hir/tree/rust-hir-item.h
+++ b/gcc/rust/hir/tree/rust-hir-item.h
@@ -2070,6 +2070,8 @@ public:
Identifier get_name () const { return name; }
+ bool has_type () const { return expr != nullptr; }
+
bool has_expr () const { return expr != nullptr; }
Type &get_type ()