[gcc r15-8437] gccrs: Load unloaded modules during toplevel resolution 2.0
Arthur Cohen
cohenarthur@gcc.gnu.org
Wed Mar 19 14:45:04 GMT 2025
https://gcc.gnu.org/g:48bde05f60025df1b565ad5b7f492ac4cf24f1ad
commit r15-8437-g48bde05f60025df1b565ad5b7f492ac4cf24f1ad
Author: Owen Avery <powerboat9.gamer@gmail.com>
Date: Tue Oct 15 22:24:29 2024 -0400
gccrs: Load unloaded modules during toplevel resolution 2.0
This may load conditionally compiled modules too eagerly.
gcc/rust/ChangeLog:
* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::visit): Load unloaded modules before attempting to
visit their items.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove issue-1089.rs.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diff:
---
gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 11 +++++++++++
gcc/testsuite/rust/compile/nr2/exclude | 1 -
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
index 92a115108e6c..c9d51039f0ee 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -76,6 +76,17 @@ TopLevel::visit (AST::Module &module)
{
insert_or_error_out (module.get_name (), module, Namespace::Types);
+ // 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
+ // TODO: make sure this is right
+ // TODO: avoid loading items if cfg attributes are present?
+ // might not be needed if this runs after early resolution?
+ // This was copied from the old early resolver method
+ // 'accumulate_escaped_macros'
+ if (module.get_kind () == AST::Module::UNLOADED)
+ module.load_items ();
+
auto sub_visitor = [this, &module] () {
for (auto &item : module.get_items ())
item->accept_vis (*this);
diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude
index f91cf3132c79..a698164fbd56 100644
--- a/gcc/testsuite/rust/compile/nr2/exclude
+++ b/gcc/testsuite/rust/compile/nr2/exclude
@@ -62,7 +62,6 @@ infer-crate-name.rs
issue-1019.rs
issue-1031.rs
issue-1034.rs
-issue-1089.rs
issue-1128.rs
issue-1129-2.rs
issue-1130.rs
More information about the Gcc-cvs
mailing list