aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2025-03-28 18:59:33 +0000
committerPhilip Herron <philip.herron@embecosm.com>2025-03-28 20:04:21 +0000
commit765121736dfe3f5b319bbe9837880deda326394e (patch)
tree2c473f9023be0474bd530782fe577bdc9f16036c /gcc/rust
parent1d93ebb1cad42c38119ec74ab5587d08c29825f2 (diff)
downloadgcc-765121736dfe3f5b319bbe9837880deda326394e.zip
gcc-765121736dfe3f5b319bbe9837880deda326394e.tar.gz
gcc-765121736dfe3f5b319bbe9837880deda326394e.tar.bz2
gccrs: Fix SEGV when type path resolver fails outright
When we resolve paths we resolve to Types first we walk each segment to the last module which has no type but then in the event that the child of a module is not found we have a null root_tyty which needs to be caught and turned into an ErrorType node. Fixes Rust-GCC#3613 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): catch nullptr root_tyty gcc/testsuite/ChangeLog: * rust/compile/issue-3613.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-type.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.cc b/gcc/rust/typecheck/rust-hir-type-check-type.cc
index 5668838..630abb0 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-type.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-type.cc
@@ -360,6 +360,13 @@ TypeCheckType::resolve_root_path (HIR::TypePath &path, size_t *offset,
seg->as_string ().c_str ());
return new TyTy::ErrorType (path.get_mappings ().get_hirid ());
}
+ else if (root_tyty == nullptr)
+ {
+ rust_error_at (seg->get_locus (),
+ "unknown reference for resolved name: %qs",
+ seg->as_string ().c_str ());
+ return new TyTy::ErrorType (path.get_mappings ().get_hirid ());
+ }
return root_tyty;
}