]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: nr2.0: Add macros 2.0 in Ribs in TopLevel visitor
authorArthur Cohen <arthur.cohen@embecosm.com>
Wed, 2 Aug 2023 10:53:20 +0000 (12:53 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:00:27 +0000 (19:00 +0100)
gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Declare
macros in the current rib if they are macros 2.0.

gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc

index 2c0e0779acd96d331683a7781b403a765debb581..c28d92270037db0eec0a151cb86eca5342ae8f68 100644 (file)
@@ -86,7 +86,8 @@ TopLevel::visit (AST::MacroRulesDefinition &macro)
 {
   // we do not insert macros in the current rib as that needs to be done in the
   // textual scope of the Early pass. we only insert them in the root of the
-  // crate if they are marked with #[macro_export]
+  // crate if they are marked with #[macro_export]. The execption to this is
+  // macros 2.0, which get resolved and inserted like regular items.
 
   if (is_macro_export (macro))
     {
@@ -103,6 +104,9 @@ TopLevel::visit (AST::MacroRulesDefinition &macro)
                         macro.get_rule_name ().as_string ().c_str ());
        }
     }
+
+  if (macro.get_kind () == AST::MacroRulesDefinition::MacroKind::DeclMacro)
+    insert_or_error_out (macro.get_rule_name (), macro, Namespace::Macros);
 }
 
 void