From dc5e01832772304e2a988406e78d3d83fe83f278 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Mon, 5 Jul 2021 12:42:31 +0100 Subject: Fix bad naming of primitive types such as u64 which ended up as usize There was a bad port over of the gccgo named_type implementation to try be simple but this ended up overwriting the names of other primitive types leading to confusing gimple debug sessions. In debugging this I have added a set of ids which are the builtin primitive types ids and we assert that this range of ids will never be overriten by other types during compilation. --- gcc/rust/backend/rust-compile-context.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'gcc/rust/backend') diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index e0c9352..5d19099 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -58,8 +58,9 @@ public: TyTy::BaseType *lookup; rust_assert (tyctx->lookup_type (ref, &lookup)); - auto compiled = TyTyCompile::compile (backend, lookup); - compiled_type_map[ref] = compiled; + Btype *compiled = TyTyCompile::compile (backend, lookup); + compiled_type_map.insert (std::pair (ref, compiled)); + builtin_range.insert (ref); } } @@ -94,7 +95,8 @@ public: void insert_compiled_type (HirId id, ::Btype *type, const TyTy::BaseType *ref = nullptr) { - compiled_type_map[id] = type; + rust_assert (builtin_range.find (id) == builtin_range.end ()); + compiled_type_map.insert (std::pair (id, type)); if (ref != nullptr) { std::pair elem (id, type); @@ -297,6 +299,7 @@ private: Resolver::TypeCheckContext *tyctx; Analysis::Mappings *mappings; ConstFold::Context *const_ctx; + std::set builtin_range; // state std::vector fn_stack; -- cgit v1.1