]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: nr2.0: Implement macro_use for modules
authorOwen Avery <powerboat9.gamer@gmail.com>
Wed, 19 Feb 2025 02:20:45 +0000 (21:20 -0500)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 24 Mar 2025 12:07:11 +0000 (13:07 +0100)
gcc/rust/ChangeLog:

* resolve/rust-early-name-resolver-2.0.cc:
Include rust-attribute-values.h.
(Early::visit): If a module has a macro_use attribute, avoid
pushing a new textual macro scope.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/resolve/rust-early-name-resolver-2.0.cc
gcc/testsuite/rust/compile/nr2/exclude

index d1e7ee0c9f8a3a5e6ab2c8825cb7c50079776f07..764be45e34c01ffde4d1f3a3ef05e0b0ad4f5794 100644 (file)
@@ -22,6 +22,7 @@
 #include "rust-toplevel-name-resolver-2.0.h"
 #include "rust-attributes.h"
 #include "rust-finalize-imports-2.0.h"
+#include "rust-attribute-values.h"
 
 namespace Rust {
 namespace Resolver2_0 {
@@ -227,11 +228,24 @@ Early::visit (AST::BlockExpr &block)
 void
 Early::visit (AST::Module &module)
 {
-  textual_scope.push ();
+  bool is_macro_use = false;
+
+  for (const auto &attr : module.get_outer_attrs ())
+    {
+      if (attr.get_path ().as_string () == Values::Attributes::MACRO_USE)
+       {
+         is_macro_use = true;
+         break;
+       }
+    }
+
+  if (!is_macro_use)
+    textual_scope.push ();
 
   DefaultResolver::visit (module);
 
-  textual_scope.pop ();
+  if (!is_macro_use)
+    textual_scope.pop ();
 }
 
 void
index 6e17eca1c20fce70f72b5834926010e14ee9c7d4..f74c2ac6c66260ad84c6be34fb73785151400b5b 100644 (file)
@@ -24,12 +24,9 @@ lookup_err1.rs
 macros/mbe/macro43.rs
 macros/mbe/macro44.rs
 macros/mbe/macro6.rs
-macros/mbe/macro_use1.rs
 multiple_bindings1.rs
 multiple_bindings2.rs
-nested_macro_use1.rs
 nested_macro_use2.rs
-nested_macro_use3.rs
 not_find_value_in_scope.rs
 privacy5.rs
 privacy8.rs