gccrs: Fix missing dead code analysis ICE on local enum definition
authorPhilip Herron <philip.herron@embecosm.com>
Tue, 27 Sep 2022 08:50:06 +0000 (09:50 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 21 Feb 2023 11:36:31 +0000 (12:36 +0100)
commit7e7a95880443ebdc763034d4e290651952f48a86
treea28d9088cf656fa718b8d7fe3be0019861167ba0
parentecc863e85efe259c799515de0c38c2297b0e3bd7
gccrs: Fix missing dead code analysis ICE on local enum definition

When resolving local enum's within a Block the name resolution info is
not at the top of the stack so this patch introduces a new mappings class
for miscellaneous name resolutions which can be used during path analaysis.

Fixes #1272

gcc/rust/ChangeLog:

* resolve/rust-name-resolver.h: Add miscellenaous item mappings.
* resolve/rust-name-resolver.cc (Resolver::insert_resolved_misc): Use
new mappings.
(Resolver::lookup_resolved_misc): Likewise.
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_segments):
Adapt function to insert into miscelleanous mappings.
* checks/lints/rust-lint-marklive.cc (MarkLive::find_ref_node_id):
Allow lookup in miscelleanous mappings in mark-live phase.

gcc/testsuite/ChangeLog:

* rust/compile/issue-1272.rs: New test.
gcc/rust/checks/lints/rust-lint-marklive.cc
gcc/rust/resolve/rust-name-resolver.cc
gcc/rust/resolve/rust-name-resolver.h
gcc/rust/typecheck/rust-hir-type-check-path.cc
gcc/testsuite/rust/compile/issue-1272.rs [new file with mode: 0644]