]> git.ipfire.org Git - people/ms/gcc.git/commitdiff
enr: Fetch module items during early name resolution
authorArthur Cohen <arthur.cohen@embecosm.com>
Thu, 2 Mar 2023 15:56:33 +0000 (16:56 +0100)
committerPhilip Herron <philip.herron@embecosm.com>
Mon, 13 Mar 2023 18:11:30 +0000 (18:11 +0000)
This is important as public macros can be present in other modules,
which would otherwise not be loaded until the expansion phase
happening right after the early name resolution.

gcc/rust/ChangeLog:

* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Move
unloaded module item loading to...
* expand/rust-attribute-visitor.cc (AttrVisitor::visit): ...here.

gcc/rust/expand/rust-attribute-visitor.cc
gcc/rust/resolve/rust-early-name-resolver.cc

index d416505eeafa634e80bbf3d95c0655f1026154f1..13ae28c0b5e405a9c353a02bf62c018aa51ca62b 100644 (file)
@@ -2148,15 +2148,6 @@ AttrVisitor::visit (AST::Module &module)
        }
     }
 
-  // Parse the module's items if they haven't been expanded and the file
-  // should be parsed (i.e isn't hidden behind an untrue or impossible cfg
-  // directive)
-  if (!module.is_marked_for_strip ()
-      && module.get_kind () == AST::Module::ModuleKind::UNLOADED)
-    {
-      module.load_items ();
-    }
-
   // strip items if required
   expand_pointer_allow_strip (module.get_items ());
 }
index 69852280630ca59da5e08dccfd213433df1e8033..b3fb5a8df961a36c7db62d94f3379b5a475244c5 100644 (file)
@@ -581,6 +581,12 @@ EarlyNameResolver::visit (AST::Method &method)
 void
 EarlyNameResolver::visit (AST::Module &module)
 {
+  // Parse the module's items if they haven't been expanded and the file
+  // should be parsed (i.e isn't hidden behind an untrue or impossible cfg
+  // directive)
+  if (module.get_kind () == AST::Module::UNLOADED)
+    module.load_items ();
+
   scoped (module.get_node_id (), [&module, this] () {
     for (auto &item : module.get_items ())
       item->accept_vis (*this);