From 1ac4b59dee2ae094bee351d67bf15321b48499a3 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Wed, 21 Aug 2024 17:14:46 +0200 Subject: gccrs: Loop on expansion if a new export has been defined When a use statement requires a reexported item it cannot find it in the same pass, an additional pass shall be performed. This means we need to detect whether a new item has been reexported and resolve until the end. gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::Early): Add dirty flag initialization. (Early::go): Set dirty flag using top level resolver. * resolve/rust-early-name-resolver-2.0.h: Add dirty flag. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::TopLevel): Initialize dirty flag. (TopLevel::insert_or_error_out): Set dirty flag on successful namespace modification. * resolve/rust-toplevel-name-resolver-2.0.h: Add dirty flag. * rust-session-manager.cc (Session::expansion): Modify fixed point condition to include name resolution modifications. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h') diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h index acb60d3..99ed653 100644 --- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h +++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h @@ -43,6 +43,8 @@ public: void go (AST::Crate &crate); + bool is_dirty () { return dirty; } + // Each import will be transformed into an instance of `ImportKind`, a class // representing some of the data we need to resolve in the // `EarlyNameResolver`. Basically, for each `UseTree` that we see in @@ -129,6 +131,10 @@ public: Namespace ns); private: + // If a new export has been defined whilst visiting the visitor is considered + // dirty + bool dirty; + // FIXME: Do we move these to our mappings? std::unordered_map node_locations; -- cgit v1.1